<script src="/aifish/common/check.pjax.js"></script>
<div id="content" class="markdown">
    <div>
<h2 id="-array-methods-"><code>“Array” Methods</code></h2>
<div>
<h3 id="-a-id-_chunkarray-size1-a-_-chunk-array-size-1-"><a id="_chunkarray-size1"></a><code>_.chunk(array, [size=1])</code></h3>
<p><a href="#_chunkarray-size1">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4624" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.chunk" title="See the npm package">Ⓝ</a></p>
<p>将 <code>array</code> 拆分成多个 <code>size</code> 长度的块，把这些块组成一个新数组。
如果 <code>array</code> 无法被分割成全部等长的块，那么最后剩余的元素将组成一个块。</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要被处理的数组。</li>
<li><code>[size=1]</code> <em>(number)</em>: 每个块的长度。</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回一个包含拆分块数组的新数组（相当于一个二维数组）。</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">chunk</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">'a'</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">,</span> <span class="token string">'c'</span><span class="token punctuation">,</span> <span class="token string">'d'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [['a', 'b'], ['c', 'd']]</span>

_<span class="token punctuation">.</span><span class="token function">chunk</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">'a'</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">,</span> <span class="token string">'c'</span><span class="token punctuation">,</span> <span class="token string">'d'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [['a', 'b', 'c'], ['d']]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_compactarray-a-_-compact-array-"><a id="_compactarray"></a><code>_.compact(array)</code></h3>
<p><a href="#_compactarray">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4655" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.compact" title="See the npm package">Ⓝ</a></p>
<p>创建一个新数组并包含原数组中所有的非假值元素。例如 <code>false</code>、<code>null</code>、
<code>0</code>、<code>""</code>、<code>undefined</code> 和 <code>NaN</code> 都是“假值”。</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 数组参数.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回过滤假值后的数组.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">compact</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2, 3]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_differencearray-values-a-_-difference-array-values-"><a id="_differencearray-values"></a><code>_.difference(array, [values])</code></h3>
<p><a href="#_differencearray-values">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4686" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.difference" title="See the npm package">Ⓝ</a></p>
<p>Creates an array of unique <code>array</code> values not included in the other
provided arrays using <a href="http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero"><code>SameValueZero</code></a>
for equality comparisons.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要过滤的数组</li>
<li><code>[values]</code> <em>(...Array)</em>: 数组需要排除掉的值</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回过滤后的数组</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">difference</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 3]</span>
_<span class="token punctuation">.</span><span class="token function">difference</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'2'</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, "2", 3]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_droparray-n1-a-_-drop-array-n-1-"><a id="_droparray-n1"></a><code>_.drop(array, [n=1])</code></h3>
<p><a href="#_droparray-n1">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4716" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.drop" title="See the npm package">Ⓝ</a></p>
<p>将 <code>array</code> 中的前 <code>n</code> 个元素去掉，然后返回剩余的部分。</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 被操作的数组。</li>
<li><code>[n=1]</code> <em>(number)</em>: 去掉的元素个数。</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回 <code>array</code> 的剩余部分。</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">drop</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [2, 3] 默认是1开始的</span>

_<span class="token punctuation">.</span><span class="token function">drop</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [3]</span>

_<span class="token punctuation">.</span><span class="token function">drop</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; []</span>

_<span class="token punctuation">.</span><span class="token function">drop</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2, 3]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_droprightarray-n1-a-_-dropright-array-n-1-"><a id="_droprightarray-n1"></a><code>_.dropRight(array, [n=1])</code></h3>
<p><a href="#_droprightarray-n1">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4751" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.dropright" title="See the npm package">Ⓝ</a></p>
<p>将 <code>array</code> 尾部的 <code>n</code> 个元素去除，并返回剩余的部分。</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要被处理数组。</li>
<li><code>[n=1]</code> <em>(number)</em>: 去掉的元素个数。</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回 <code>array</code> 的剩余部分。</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">dropRight</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2]</span>

_<span class="token punctuation">.</span><span class="token function">dropRight</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1]</span>

_<span class="token punctuation">.</span><span class="token function">dropRight</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; []</span>

_<span class="token punctuation">.</span><span class="token function">dropRight</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2, 3]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_droprightwhilearray-predicate_identity-thisarg-a-_-droprightwhile-array-predicate-_-identity-thisarg-"><a id="_droprightwhilearray-predicate_identity-thisarg"></a><code>_.dropRightWhile(array, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_droprightwhilearray-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4812" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.droprightwhile" title="See the npm package">Ⓝ</a></p>
<p>从尾端查询（右数）数组 <code>array</code> ，第一个不满足<code>predicate</code> 条件的元素开始截取数组. <code>thisArg</code>为<code>predicate</code> 条件执行上下文对象绑定的参数 .
<br>
<br>
参数 <code>predicate</code> 提供的是一个属性名称，就通过提供的参数使用 <code>_.property</code>方法返回一个回调函数
<br>
<br>
如果参数<code>thisArg</code>提供的话，就使用 <code>_.matchesProperty</code>方法匹配相同的属性值，相同返回true,不同返回false
<br>
<br>
如果参数<code>predicate</code>提供的是一个对象，就使用 <code>_.matches</code>方法匹配相同的元素，相同返回true,不同返回false</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要查询的数组</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: 数组迭代判断条件</li>
<li><code>[thisArg]</code> <em>(*)</em>: 对应 <code>predicate</code> 属性的值.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回截取元素后的数组</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">dropRightWhile</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> n <span class="token operator">&gt;</span> <span class="token number">1</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1]</span>

<span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span>  <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>    <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'pebbles'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// using the `_.matches` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">dropRightWhile</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'pebbles'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['barney', 'fred']</span>

<span class="token comment" spellcheck="true">// using the `_.matchesProperty` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">dropRightWhile</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['barney']</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">dropRightWhile</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['barney', 'fred', 'pebbles']</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_dropwhilearray-predicate_identity-thisarg-a-_-dropwhile-array-predicate-_-identity-thisarg-"><a id="_dropwhilearray-predicate_identity-thisarg"></a><code>_.dropWhile(array, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_dropwhilearray-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4867" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.dropwhile" title="See the npm package">Ⓝ</a></p>
<p>从开头查询（左数起）数组 <code>array</code> ，第一个不满足<code>predicate</code> 条件的元素开始截取数组. <code>thisArg</code>为<code>predicate</code> 条件执行上下文对象绑定的参数 .
<br>
<br>
参数 <code>predicate</code> 提供的是一个属性名称，就通过提供的参数使用 <code>_.property</code>方法返回一个回调函数
<br>
<br>
如果参数<code>thisArg</code>提供的话，就使用 <code>_.matchesProperty</code>方法匹配相同的属性值，相同返回true,不同返回false
<br>
<br>
如果参数<code>predicate</code>提供的是一个对象，就使用 <code>_.matches</code>方法匹配相同的元素，相同返回true,不同返回false</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要查询的数组</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: 数组遍历的条件</li>
<li><code>[thisArg]</code> <em>(*)</em>:  对应 <code>predicate</code> 属性的值.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回截取元素后的数组</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">dropWhile</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> n <span class="token operator">&lt;</span> <span class="token number">3</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [3]</span>

<span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span>  <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>    <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'pebbles'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// using the `_.matches` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">dropWhile</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['fred', 'pebbles']</span>

<span class="token comment" spellcheck="true">// using the `_.matchesProperty` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">dropWhile</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['pebbles']</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">dropWhile</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['barney', 'fred', 'pebbles']</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_fillarray-value-start0-endarraylength-a-_-fill-array-value-start-0-end-array-length-"><a id="_fillarray-value-start0-endarraylength"></a><code>_.fill(array, value, [start=0], [end=array.length])</code></h3>
<p><a href="#_fillarray-value-start0-endarraylength">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4901" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.fill" title="See the npm package">Ⓝ</a></p>
<p>使用 <code>value</code> 值来填充（也就是替换） <code>array</code>，从<code>start</code>位置开始, 到<code>end</code>位置结束（但不包含end位置）
<br>
<br>
<strong>Note:</strong> 这是个改变数组的方法</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要填充的数组.</li>
<li><code>value</code> <em>(*)</em>: 填充 <code>array</code> 元素的值.</li>
<li><code>[start=0]</code> <em>(number)</em>: 起始位置（包含）</li>
<li><code>[end=array.length]</code> <em>(number)</em>: 结束位置（不含）</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回 <code>array</code> .</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> array <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">fill</span><span class="token punctuation">(</span>array<span class="token punctuation">,</span> <span class="token string">'a'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>array<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['a', 'a', 'a']</span>

_<span class="token punctuation">.</span><span class="token function">fill</span><span class="token punctuation">(</span><span class="token function">Array</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [2, 2, 2]</span>

_<span class="token punctuation">.</span><span class="token function">fill</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">,</span> <span class="token number">8</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string">'*'</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [4, '*', 8]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_findindexarray-predicate_identity-thisarg-a-_-findindex-array-predicate-_-identity-thisarg-"><a id="_findindexarray-predicate_identity-thisarg"></a><code>_.findIndex(array, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_findindexarray-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4961" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.findindex" title="See the npm package">Ⓝ</a></p>
<p>该方法类似 <code>_.find</code>，区别是该方法返回的是符合 <code>predicate</code>条件的第一个元素的索引，而不是返回元素本身.
<br>
<br>
参数 <code>predicate</code> 提供的是一个属性名称，就通过提供的参数使用 <code>_.property</code>方法返回一个回调函数
<br>
<br>
如果参数<code>thisArg</code>值提供的话，就使用 <code>_.matchesProperty</code>方法匹配相同的属性值，相同返回true,不同返回false
<br>
<br>
如果参数<code>predicate</code>提供的是一个对象，就使用 <code>_.matches</code>方法匹配相同的元素，相同返回true,不同返回false</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要搜索的数组</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: 数组遍历满足的条件</li>
<li><code>[thisArg]</code> <em>(*)</em>: 对应 <code>predicate</code> 属性的值.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(number)</em>:  返回符合查询条件的元素的索引值, 未找到则返回 <code>-1</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span>  <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>    <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'pebbles'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">findIndex</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>chr<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> chr<span class="token punctuation">.</span>user <span class="token operator">==</span> <span class="token string">'barney'</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 0</span>

<span class="token comment" spellcheck="true">// using the `_.matches` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">findIndex</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 1</span>

<span class="token comment" spellcheck="true">// using the `_.matchesProperty` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">findIndex</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 0</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">findIndex</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 2</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_findlastindexarray-predicate_identity-thisarg-a-_-findlastindex-array-predicate-_-identity-thisarg-"><a id="_findlastindexarray-predicate_identity-thisarg"></a><code>_.findLastIndex(array, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_findlastindexarray-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5011" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.findlastindex" title="See the npm package">Ⓝ</a></p>
<p>该方法类似 <code>_.findIndex</code> ，区别是其从右到左遍历数组.
<br>
<br>
该方法类似 <code>_.find</code>，区别是该方法返回的是符合 <code>predicate</code>条件的第一个元素的索引，而不是返回元素本身.
<br>
<br>
参数 <code>predicate</code> 提供的是一个属性名称，就通过提供的参数使用 <code>_.property</code>方法返回一个回调函数
<br>
<br>
如果参数<code>thisArg</code>值提供的话，就使用 <code>_.matchesProperty</code>方法匹配相同的属性值，相同返回true,不同返回false
<br>
<br>
如果参数<code>predicate</code>提供的是一个对象，就使用 <code>_.matches</code>方法匹配相同的元素，相同返回true,不同返回false</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要查询的数组</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: 遍历数组条件</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>predicate</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(number)</em>:  返回匹配数组元素的索引值, 否则返回 <code>-1</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span>  <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>    <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'pebbles'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">findLastIndex</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>chr<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> chr<span class="token punctuation">.</span>user <span class="token operator">==</span> <span class="token string">'pebbles'</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 2</span>

<span class="token comment" spellcheck="true">// using the `_.matches` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">findLastIndex</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 0</span>

<span class="token comment" spellcheck="true">// using the `_.matchesProperty` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">findLastIndex</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 2</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">findLastIndex</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 0</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_firstarray-a-_-first-array-"><a id="_firstarray"></a><code>_.first(array)</code></h3>
<p><a href="#_firstarray">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5030" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.first" title="See the npm package">Ⓝ</a></p>
<p>获取数组 <code>array</code>的第一个元素</p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em>_.head</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要查询的数组</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(*)</em>:  返回数组的第一个元素</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">first</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 1</span>

_<span class="token punctuation">.</span><span class="token function">first</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; undefined</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_flattenarray-isdeep-a-_-flatten-array-isdeep-"><a id="_flattenarray-isdeep"></a><code>_.flatten(array, [isDeep])</code></h3>
<p><a href="#_flattenarray-isdeep">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5054" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.flatten" title="See the npm package">Ⓝ</a></p>
<p>可以理解为将嵌套数组的维数减少，<code>flattened</code>（平坦）. 如果 <code>isDeep</code> 值为 <code>true</code> 时，嵌套数组将递归为一维数组, 否则只减少嵌套数组一个级别的维数.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要<code>flattened</code>（减少维数）的嵌套数组</li>
<li><code>[isDeep]</code> <em>(boolean)</em>: 是否深递归</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回处理后的数组</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">flatten</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2, 3, [4]]</span>

<span class="token comment" spellcheck="true">// using `isDeep`</span>
_<span class="token punctuation">.</span><span class="token function">flatten</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2, 3, 4]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_flattendeeparray-a-_-flattendeep-array-"><a id="_flattendeeparray"></a><code>_.flattenDeep(array)</code></h3>
<p><a href="#_flattendeeparray">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5075" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.flattendeep" title="See the npm package">Ⓝ</a></p>
<p>递归地平坦一个嵌套的数组.相当于<code>_.flatten(array, true)</code></p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回处理后的数组.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">flattenDeep</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2, 3, 4]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_indexofarray-value-fromindex0-a-_-indexof-array-value-fromindex-0-"><a id="_indexofarray-value-fromindex0"></a><code>_.indexOf(array, value, [fromIndex=0])</code></h3>
<p><a href="#_indexofarray-value-fromindex0">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5108" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.indexof" title="See the npm package">Ⓝ</a></p>
<p>获取<code>value</code>在数组 <code>array</code>所在的索引值
使用 <a href="http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero"><code>SameValueZero</code></a>
来保证比较的质量（第一个全等<code>===</code>的元素）. 如果 <code>fromIndex</code> 值是负数, 则从<code>array</code>末尾起算. 如果 <code>fromIndex</code>为true时，对已排序的数组<code>array</code>执行二分（二进制）查找</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要查找的数组</li>
<li><code>value</code> <em>(*)</em>: 需要查找的元素</li>
<li><code>[fromIndex=0]</code> <em>(boolean|number)</em>: 查询的位置或者<code>true</code>值时对一个已排序的数组进行二分查找.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(number)</em>:  返回元素在数组中的索引位置, else <code>-1</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 1</span>

<span class="token comment" spellcheck="true">// using `fromIndex`</span>
_<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 3</span>

<span class="token comment" spellcheck="true">// performing a binary search</span>
_<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token keyword">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 2</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_initialarray-a-_-initial-array-"><a id="_initialarray"></a><code>_.initial(array)</code></h3>
<p><a href="#_initialarray">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5139" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.initial" title="See the npm package">Ⓝ</a></p>
<p>去除数组最后一个元素<code>array</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要查询的数组.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回截取的数组<code>array</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">initial</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_intersectionarrays-a-_-intersection-arrays-"><a id="_intersectionarrays"></a><code>_.intersection([arrays])</code></h3>
<p><a href="#_intersectionarrays">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5157" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.intersection" title="See the npm package">Ⓝ</a></p>
<p>取出各数组中全等的元素，使用 <a href="http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero"><code>SameValueZero</code></a>方式平等比较</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[arrays]</code> <em>(...Array)</em>: 需要检查的数组数组.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回共有元素的数组.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">intersection</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [2]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_lastarray-a-_-last-array-"><a id="_lastarray"></a><code>_.last(array)</code></h3>
<p><a href="#_lastarray">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5207" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.last" title="See the npm package">Ⓝ</a></p>
<p>取出数组的最后一个元素 <code>array</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 查询的数组</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(*)</em>:  返回 <code>array</code>的最后一个元素.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">last</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 3</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_lastindexofarray-value-fromindexarraylength-1-a-_-lastindexof-array-value-fromindex-array-length-1-"><a id="_lastindexofarray-value-fromindexarraylength-1"></a><code>_.lastIndexOf(array, value, [fromIndex=array.length-1])</code></h3>
<p><a href="#_lastindexofarray-value-fromindexarraylength-1">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5237" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.lastindexof" title="See the npm package">Ⓝ</a></p>
<p>该方法类似 <code>_.indexOf</code> ，只不过<code>_.lastIndexOf</code>是从右向左遍历数组<code>array</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 查询的数组</li>
<li><code>value</code> <em>(*)</em>:查询的元素.</li>
<li><code>[fromIndex=array.length-1]</code> <em>(boolean|number)</em>: 查询的起始位置或者为 <code>true</code> 时对已排序的数组进行二分查找.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(number)</em>:  返回第一个匹配值的索引值, 查询不到则返回 <code>-1</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">lastIndexOf</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 3</span>

<span class="token comment" spellcheck="true">// using `fromIndex`</span>
_<span class="token punctuation">.</span><span class="token function">lastIndexOf</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 1</span>

<span class="token comment" spellcheck="true">// performing a binary search</span>
_<span class="token punctuation">.</span><span class="token function">lastIndexOf</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token keyword">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 3</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_pullarray-values-a-_-pull-array-values-"><a id="_pullarray-values"></a><code>_.pull(array, [values])</code></h3>
<p><a href="#_pullarray-values">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5285" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.pull" title="See the npm package">Ⓝ</a></p>
<p>移除数组<code>array</code>中所有和 values 相等的元素，使用
<a href="http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero"><code>SameValueZero</code></a>
进行全等比较
<br>
<br>
<strong>Note:</strong> 不像 <code>_.without</code>方法,此方法改变了数组 <code>array</code>（并不是原来的数组了）.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 修改的数组</li>
<li><code>[values]</code> <em>(...*)</em>: 移除的元素</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>: 返回数组 <code>array</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> array <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">pull</span><span class="token punctuation">(</span>array<span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>array<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 1]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_pullatarray-indexes-a-_-pullat-array-indexes-"><a id="_pullatarray-indexes"></a><code>_.pullAt(array, [indexes])</code></h3>
<p><a href="#_pullatarray-indexes">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5332" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.pullat" title="See the npm package">Ⓝ</a></p>
<p>移除指定索引的数组元素，并返回移除的元素，索引值明确给出或者是索引数组.
<br>
<br>
<strong>Note:</strong> 和 <code>_.at</code>方法不同, 此方法改变了数组 <code>array</code>（改变后一个新数组了）.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要修改的数组</li>
<li><code>[indexes]</code> <em>(...(number|number[])</em>: 需要移除元素的索引, 数组的索引值或者索引数组.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回移除元素后的新数组；</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> array <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token number">5</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">15</span><span class="token punctuation">,</span> <span class="token number">20</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> evens <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">pullAt</span><span class="token punctuation">(</span>array<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>array<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [5, 15]</span>

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>evens<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [10, 20]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_removearray-predicate_identity-thisarg-a-_-remove-array-predicate-_-identity-thisarg-"><a id="_removearray-predicate_identity-thisarg"></a><code>_.remove(array, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_removearray-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5379" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.remove" title="See the npm package">Ⓝ</a></p>
<p>移除数组 <code>array</code> 中满足 <code>predicate</code> 条件的所有元素 ，返回的是被移除元素数组.
<br>
<br>
如果参数 <code>predicate</code>提供的是一个属性，则使用 <code>_.property</code>方法来判断
<br>
<br>
如果提供了参数 <code>thisArg</code> ，则使用 <code>_.matchesProperty</code>方法来判断属性是否等于此<code>value</code></p>
<p><br>
<br>
如果 <code>predicate</code>参数是一个对象，则使用 <code>_.matches</code>方法来判断比较这个对象
<br>
<br>
<strong>Note:</strong> 和方法 <code>_.filter</code>不一样, 此方法彻底改变数组<code>array</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要修改的数组</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: 遍历判断的方法</li>
<li><code>[thisArg]</code> <em>(*)</em>: 和参数<code>predicate</code>绑定</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回被移除元素组成的数组</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> array <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> evens <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span>array<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> n <span class="token operator">%</span> <span class="token number">2</span> <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>array<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 3]</span>

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>evens<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [2, 4]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_restarray-a-_-rest-array-"><a id="_restarray"></a><code>_.rest(array)</code></h3>
<p><a href="#_restarray">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5414" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.rest" title="See the npm package">Ⓝ</a></p>
<p>获取数组 <code>array</code>第一个元素除外的所有元素.</p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em>_.tail</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要查询的数组</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回截取的 <code>array</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">rest</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [2, 3]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_slicearray-start0-endarraylength-a-_-slice-array-start-0-end-array-length-"><a id="_slicearray-start0-endarraylength"></a><code>_.slice(array, [start=0], [end=array.length])</code></h3>
<p><a href="#_slicearray-start0-endarraylength">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5432" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.slice" title="See the npm package">Ⓝ</a></p>
<p>从<code>start</code>位置到 <code>end</code>（但不包含end位置），截取 <code>array</code>数组
<br>
<br>
<strong>Note:</strong> 此方法是用来在IE9以下版本替代 <code>Array#slice</code>来支持节点列表，确保密集数组返回</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要截取的数组.</li>
<li><code>[start=0]</code> <em>(number)</em>: 截取开始位置</li>
<li><code>[end=array.length]</code> <em>(number)</em>: 结束位置（不包含）</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回截取后的数组 <code>array</code>.</p>
<hr>
</div>
<div>
<h3 id="-a-id-_sortedindexarray-value-iteratee_identity-thisarg-a-_-sortedindex-array-value-iteratee-_-identity-thisarg-"><a id="_sortedindexarray-value-iteratee_identity-thisarg"></a><code>_.sortedIndex(array, value, [iteratee=_.identity], [thisArg])</code></h3>
<p><a href="#_sortedindexarray-value-iteratee_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5492" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.sortedindex" title="See the npm package">Ⓝ</a></p>
<p>Uses a binary search to determine the lowest index at which <code>value</code> should
be inserted into <code>array</code> in order to maintain its sort order. If an iteratee
function is provided it's invoked for <code>value</code> and each element of <code>array</code>
to compute their sort ranking. The iteratee is bound to <code>thisArg</code> and
invoked with one argument; (value).
<br>
<br>
If a property name is provided for <code>iteratee</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>iteratee</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要检查的数组</li>
<li><code>value</code> <em>(*)</em>: 插入的判断参数</li>
<li><code>[iteratee=_.identity]</code> <em>(Function|Object|string)</em>: 遍历方法</li>
<li><code>[thisArg]</code> <em>(*)</em>:  <code>iteratee</code>的绑定值</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(number)</em>:  返回<code>value</code> 应该插入数组<code>array</code>位置的索引值</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">sortedIndex</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">30</span><span class="token punctuation">,</span> <span class="token number">50</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">40</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 1</span>

_<span class="token punctuation">.</span><span class="token function">sortedIndex</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 2</span>

<span class="token keyword">var</span> dict <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token string">'data'</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token string">'thirty'</span><span class="token punctuation">:</span> <span class="token number">30</span><span class="token punctuation">,</span> <span class="token string">'forty'</span><span class="token punctuation">:</span> <span class="token number">40</span><span class="token punctuation">,</span> <span class="token string">'fifty'</span><span class="token punctuation">:</span> <span class="token number">50</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// using an iteratee function</span>
_<span class="token punctuation">.</span><span class="token function">sortedIndex</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">'thirty'</span><span class="token punctuation">,</span> <span class="token string">'fifty'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string">'forty'</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>word<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>data<span class="token punctuation">[</span>word<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> dict<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 1</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">sortedIndex</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token punctuation">{</span> <span class="token string">'x'</span><span class="token punctuation">:</span> <span class="token number">30</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'x'</span><span class="token punctuation">:</span> <span class="token number">50</span> <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'x'</span><span class="token punctuation">:</span> <span class="token number">40</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token string">'x'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 1</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_sortedlastindexarray-value-iteratee_identity-thisarg-a-_-sortedlastindex-array-value-iteratee-_-identity-thisarg-"><a id="_sortedlastindexarray-value-iteratee_identity-thisarg"></a><code>_.sortedLastIndex(array, value, [iteratee=_.identity], [thisArg])</code></h3>
<p><a href="#_sortedlastindexarray-value-iteratee_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5514" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.sortedlastindex" title="See the npm package">Ⓝ</a></p>
<p> 用法类似于 <code>_.sortedIndex</code> ,不同的是从右至左计算插入的位置</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要检查的数组</li>
<li><code>value</code> <em>(*)</em>: 插入的判断参数</li>
<li><code>[iteratee=_.identity]</code> <em>(Function|Object|string)</em>: 遍历方法</li>
<li><code>[thisArg]</code> <em>(*)</em>:  <code>iteratee</code>的绑定值</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(number)</em>:  返回<code>value</code> 应该插入数组<code>array</code>位置的索引值</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">sortedLastIndex</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 4</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_takearray-n1-a-_-take-array-n-1-"><a id="_takearray-n1"></a><code>_.take(array, [n=1])</code></h3>
<p><a href="#_takearray-n1">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5540" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.take" title="See the npm package">Ⓝ</a></p>
<p> 从数组的起始位置开始，取<code>n</code>个元素;n默认是1</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要查询的数组</li>
<li><code>[n=1]</code> <em>(number)</em>: 获取的元素个数</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>: 返回取得的数组</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">take</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1]</span>

_<span class="token punctuation">.</span><span class="token function">take</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2]</span>

_<span class="token punctuation">.</span><span class="token function">take</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2, 3]</span>

_<span class="token punctuation">.</span><span class="token function">take</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; []</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_takerightarray-n1-a-_-takeright-array-n-1-"><a id="_takerightarray-n1"></a><code>_.takeRight(array, [n=1])</code></h3>
<p><a href="#_takerightarray-n1">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5575" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.takeright" title="See the npm package">Ⓝ</a></p>
<p>从数组右侧开始 取得 <code>n</code> 个元素;n默认为1 </p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: 需要查询的数组</li>
<li><code>[n=1]</code> <em>(number)</em>: 获取的元素个数</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  返回截取的数组 <code>array</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">takeRight</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [3]</span>

_<span class="token punctuation">.</span><span class="token function">takeRight</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [2, 3]</span>

_<span class="token punctuation">.</span><span class="token function">takeRight</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2, 3]</span>

_<span class="token punctuation">.</span><span class="token function">takeRight</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; []</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_takerightwhilearray-predicate_identity-thisarg-a-_-takerightwhile-array-predicate-_-identity-thisarg-"><a id="_takerightwhilearray-predicate_identity-thisarg"></a><code>_.takeRightWhile(array, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_takerightwhilearray-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5636" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.takerightwhile" title="See the npm package">Ⓝ</a></p>
<p>Creates a slice of <code>array</code> with elements taken from the end. Elements are
taken until <code>predicate</code> returns falsey. The predicate is bound to <code>thisArg</code>
and invoked with three arguments: (value, index, array).
<br>
<br>
If a property name is provided for <code>predicate</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>predicate</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: The array to query.</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>predicate</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the slice of <code>array</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">takeRightWhile</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> n <span class="token operator">&gt;</span> <span class="token number">1</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [2, 3]</span>

<span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span>  <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>    <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'pebbles'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// using the `_.matches` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">takeRightWhile</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'pebbles'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['pebbles']</span>

<span class="token comment" spellcheck="true">// using the `_.matchesProperty` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">takeRightWhile</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['fred', 'pebbles']</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">takeRightWhile</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; []</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_takewhilearray-predicate_identity-thisarg-a-_-takewhile-array-predicate-_-identity-thisarg-"><a id="_takewhilearray-predicate_identity-thisarg"></a><code>_.takeWhile(array, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_takewhilearray-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5691" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.takewhile" title="See the npm package">Ⓝ</a></p>
<p>Creates a slice of <code>array</code> with elements taken from the beginning. Elements
are taken until <code>predicate</code> returns falsey. The predicate is bound to
<code>thisArg</code> and invoked with three arguments: (value, index, array).
<br>
<br>
If a property name is provided for <code>predicate</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>predicate</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: The array to query.</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>predicate</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the slice of <code>array</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">takeWhile</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> n <span class="token operator">&lt;</span> <span class="token number">3</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2]</span>

<span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span>  <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>    <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'pebbles'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// using the `_.matches` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">takeWhile</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['barney']</span>

<span class="token comment" spellcheck="true">// using the `_.matchesProperty` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">takeWhile</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['barney', 'fred']</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">takeWhile</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; []</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_unionarrays-a-_-union-arrays-"><a id="_unionarrays"></a><code>_.union([arrays])</code></h3>
<p><a href="#_unionarrays">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5712" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.union" title="See the npm package">Ⓝ</a></p>
<p>Creates an array of unique values, in order, from all of the provided arrays
using <a href="http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero"><code>SameValueZero</code></a>
for equality comparisons.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[arrays]</code> <em>(...Array)</em>: The arrays to inspect.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new array of combined values.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">union</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2, 4]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_uniqarray-issorted-iteratee-thisarg-a-_-uniq-array-issorted-iteratee-thisarg-"><a id="_uniqarray-issorted-iteratee-thisarg"></a><code>_.uniq(array, [isSorted], [iteratee], [thisArg])</code></h3>
<p><a href="#_uniqarray-issorted-iteratee-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5765" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.uniq" title="See the npm package">Ⓝ</a></p>
<p>Creates a duplicate-free version of an array, using
<a href="http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero"><code>SameValueZero</code></a>
for equality comparisons, in which only the first occurence of each element
is kept. Providing <code>true</code> for <code>isSorted</code> performs a faster search algorithm
for sorted arrays. If an iteratee function is provided it's invoked for
each element in the array to generate the criterion by which uniqueness
is computed. The <code>iteratee</code> is bound to <code>thisArg</code> and invoked with three
arguments: (value, index, array).
<br>
<br>
If a property name is provided for <code>iteratee</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>iteratee</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em>_.unique</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: The array to inspect.</li>
<li><code>[isSorted]</code> <em>(boolean)</em>: Specify the array is sorted.</li>
<li><code>[iteratee]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new duplicate-value-free array.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">uniq</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [2, 1]</span>

<span class="token comment" spellcheck="true">// using `isSorted`</span>
_<span class="token punctuation">.</span><span class="token function">uniq</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2]</span>

<span class="token comment" spellcheck="true">// using an iteratee function</span>
_<span class="token punctuation">.</span><span class="token function">uniq</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2.5</span><span class="token punctuation">,</span> <span class="token number">1.5</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">floor</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> Math<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2.5]</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">uniq</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token punctuation">{</span> <span class="token string">'x'</span><span class="token punctuation">:</span> <span class="token number">1</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'x'</span><span class="token punctuation">:</span> <span class="token number">2</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'x'</span><span class="token punctuation">:</span> <span class="token number">1</span> <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string">'x'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [{ 'x': 1 }, { 'x': 2 }]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_unziparray-a-_-unzip-array-"><a id="_unziparray"></a><code>_.unzip(array)</code></h3>
<p><a href="#_unziparray">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5802" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.unzip" title="See the npm package">Ⓝ</a></p>
<p>This method is like <code>_.zip</code> except that it accepts an array of grouped
elements and creates an array regrouping the elements to their pre-zip
configuration.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: The array of grouped elements to process.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new array of regrouped elements.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> zipped <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">zip</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">'fred'</span><span class="token punctuation">,</span> <span class="token string">'barney'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">30</span><span class="token punctuation">,</span> <span class="token number">40</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token keyword">true</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [['fred', 30, true], ['barney', 40, false]]</span>

_<span class="token punctuation">.</span><span class="token function">unzip</span><span class="token punctuation">(</span>zipped<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [['fred', 'barney'], [30, 40], [true, false]]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_unzipwitharray-iteratee-thisarg-a-_-unzipwith-array-iteratee-thisarg-"><a id="_unzipwitharray-iteratee-thisarg"></a><code>_.unzipWith(array, [iteratee], [thisArg])</code></h3>
<p><a href="#_unzipwitharray-iteratee-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5842" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.unzipwith" title="See the npm package">Ⓝ</a></p>
<p>This method is like <code>_.unzip</code> except that it accepts an iteratee to specify
how regrouped values should be combined. The <code>iteratee</code> is bound to <code>thisArg</code>
and invoked with four arguments: (accumulator, value, index, group).</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: The array of grouped elements to process.</li>
<li><code>[iteratee]</code> <em>(Function)</em>: The function to combine regrouped values.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new array of regrouped elements.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> zipped <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">zip</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">20</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">100</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [[1, 10, 100], [2, 20, 200]]</span>

_<span class="token punctuation">.</span><span class="token function">unzipWith</span><span class="token punctuation">(</span>zipped<span class="token punctuation">,</span> _<span class="token punctuation">.</span>add<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [3, 30, 300]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_withoutarray-values-a-_-without-array-values-"><a id="_withoutarray-values"></a><code>_.without(array, [values])</code></h3>
<p><a href="#_withoutarray-values">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5873" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.without" title="See the npm package">Ⓝ</a></p>
<p>Creates an array excluding all provided values using
<a href="http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero"><code>SameValueZero</code></a>
for equality comparisons.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>array</code> <em>(Array)</em>: The array to filter.</li>
<li><code>[values]</code> <em>(...*)</em>: The values to exclude.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new array of filtered values.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">without</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [3]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_xorarrays-a-_-xor-arrays-"><a id="_xorarrays"></a><code>_.xor([arrays])</code></h3>
<p><a href="#_xorarrays">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5893" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.xor" title="See the npm package">Ⓝ</a></p>
<p>Creates an array of unique values that is the <a href="https://en.wikipedia.org/wiki/Symmetric_difference">symmetric difference</a>
of the provided arrays.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[arrays]</code> <em>(...Array)</em>: The arrays to inspect.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new array of values.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">xor</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 4]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_ziparrays-a-_-zip-arrays-"><a id="_ziparrays"></a><code>_.zip([arrays])</code></h3>
<p><a href="#_ziparrays">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5923" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.zip" title="See the npm package">Ⓝ</a></p>
<p>Creates an array of grouped elements, the first of which contains the first
elements of the given arrays, the second of which contains the second elements
of the given arrays, and so on.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[arrays]</code> <em>(...Array)</em>: The arrays to process.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new array of grouped elements.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">zip</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">'fred'</span><span class="token punctuation">,</span> <span class="token string">'barney'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">30</span><span class="token punctuation">,</span> <span class="token number">40</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token keyword">true</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [['fred', 30, true], ['barney', 40, false]]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_zipobjectprops-values-a-_-zipobject-props-values-"><a id="_zipobjectprops-values"></a><code>_.zipObject(props, [values=[]])</code></h3>
<p><a href="#_zipobjectprops-values">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5946" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.zipobject" title="See the npm package">Ⓝ</a></p>
<p>The inverse of <code>_.pairs</code>; this method returns an object composed from arrays
of property names and values. Provide either a single two dimensional array,
e.g. <code>[[key1, value1], [key2, value2]]</code> or two arrays, one of property names
and one of corresponding values.</p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em>_.object</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>props</code> <em>(Array)</em>: The property names.</li>
<li><code>[values=[]]</code> <em>(Array)</em>: The property values.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the new object.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">zipObject</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token punctuation">[</span><span class="token string">'fred'</span><span class="token punctuation">,</span> <span class="token number">30</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token number">40</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'fred': 30, 'barney': 40 }</span>

_<span class="token punctuation">.</span><span class="token function">zipObject</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">'fred'</span><span class="token punctuation">,</span> <span class="token string">'barney'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">30</span><span class="token punctuation">,</span> <span class="token number">40</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'fred': 30, 'barney': 40 }</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_zipwitharrays-iteratee-thisarg-a-_-zipwith-arrays-iteratee-thisarg-"><a id="_zipwitharrays-iteratee-thisarg"></a><code>_.zipWith([arrays], [iteratee], [thisArg])</code></h3>
<p><a href="#_zipwitharrays-iteratee-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5982" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.zipwith" title="See the npm package">Ⓝ</a></p>
<p>This method is like <code>_.zip</code> except that it accepts an iteratee to specify
how grouped values should be combined. The <code>iteratee</code> is bound to <code>thisArg</code>
and invoked with four arguments: (accumulator, value, index, group).</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[arrays]</code> <em>(...Array)</em>: The arrays to process.</li>
<li><code>[iteratee]</code> <em>(Function)</em>: The function to combine grouped values.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new array of grouped elements.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">zipWith</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">20</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">100</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">]</span><span class="token punctuation">,</span> _<span class="token punctuation">.</span>add<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [111, 222]</span>
</code></pre>
<hr>
</div>
</div>
<div>
<h2 id="-chain-methods-"><code>“Chain” Methods</code></h2>
<div>
<h3 id="-a-id-_value-a-_-value-"><a id="_value"></a><code>_(value)</code></h3>
<p><a href="#_value">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L944" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a></p>
<p>Creates a <code>lodash</code> object which wraps <code>value</code> to enable implicit chaining.
Methods that operate on and return arrays, collections, and functions can
be chained together. Methods that retrieve a single value or may return a
primitive value will automatically end the chain returning the unwrapped
value. Explicit chaining may be enabled using <code>_.chain</code>. The execution of
chained methods is lazy, that is, execution is deferred until <code>_#value</code>
is implicitly or explicitly called.
<br>
<br>
Lazy evaluation allows several methods to support shortcut fusion. Shortcut
fusion is an optimization strategy which merge iteratee calls; this can help
to avoid the creation of intermediate data structures and greatly reduce the
number of iteratee executions.
<br>
<br>
Chaining is supported in custom builds as long as the <code>_#value</code> method is
directly or indirectly included in the build.
<br>
<br>
In addition to lodash methods, wrappers have <code>Array</code> and <code>String</code> methods.
<br>
<br>
The wrapper <code>Array</code> methods are:<br>
<code>concat</code>, <code>join</code>, <code>pop</code>, <code>push</code>, <code>reverse</code>, <code>shift</code>, <code>slice</code>, <code>sort</code>,
<code>splice</code>, and <code>unshift</code>
<br>
<br>
The wrapper <code>String</code> methods are:<br>
<code>replace</code> and <code>split</code>
<br>
<br>
The wrapper methods that support shortcut fusion are:<br>
<code>compact</code>, <code>drop</code>, <code>dropRight</code>, <code>dropRightWhile</code>, <code>dropWhile</code>, <code>filter</code>,
<code>first</code>, <code>initial</code>, <code>last</code>, <code>map</code>, <code>pluck</code>, <code>reject</code>, <code>rest</code>, <code>reverse</code>,
<code>slice</code>, <code>take</code>, <code>takeRight</code>, <code>takeRightWhile</code>, <code>takeWhile</code>, <code>toArray</code>,
and <code>where</code>
<br>
<br>
The chainable wrapper methods are:<br>
<code>after</code>, <code>ary</code>, <code>assign</code>, <code>at</code>, <code>before</code>, <code>bind</code>, <code>bindAll</code>, <code>bindKey</code>,
<code>callback</code>, <code>chain</code>, <code>chunk</code>, <code>commit</code>, <code>compact</code>, <code>concat</code>, <code>constant</code>,
<code>countBy</code>, <code>create</code>, <code>curry</code>, <code>debounce</code>, <code>defaults</code>, <code>defaultsDeep</code>,
<code>defer</code>, <code>delay</code>, <code>difference</code>, <code>drop</code>, <code>dropRight</code>, <code>dropRightWhile</code>,
<code>dropWhile</code>, <code>fill</code>, <code>filter</code>, <code>flatten</code>, <code>flattenDeep</code>, <code>flow</code>, <code>flowRight</code>,
<code>forEach</code>, <code>forEachRight</code>, <code>forIn</code>, <code>forInRight</code>, <code>forOwn</code>, <code>forOwnRight</code>,
<code>functions</code>, <code>groupBy</code>, <code>indexBy</code>, <code>initial</code>, <code>intersection</code>, <code>invert</code>,
<code>invoke</code>, <code>keys</code>, <code>keysIn</code>, <code>map</code>, <code>mapKeys</code>, <code>mapValues</code>, <code>matches</code>,
<code>matchesProperty</code>, <code>memoize</code>, <code>merge</code>, <code>method</code>, <code>methodOf</code>, <code>mixin</code>,
<code>modArgs</code>, <code>negate</code>, <code>omit</code>, <code>once</code>, <code>pairs</code>, <code>partial</code>, <code>partialRight</code>,
<code>partition</code>, <code>pick</code>, <code>plant</code>, <code>pluck</code>, <code>property</code>, <code>propertyOf</code>, <code>pull</code>,
<code>pullAt</code>, <code>push</code>, <code>range</code>, <code>rearg</code>, <code>reject</code>, <code>remove</code>, <code>rest</code>, <code>restParam</code>,
<code>reverse</code>, <code>set</code>, <code>shuffle</code>, <code>slice</code>, <code>sort</code>, <code>sortBy</code>, <code>sortByAll</code>,
<code>sortByOrder</code>, <code>splice</code>, <code>spread</code>, <code>take</code>, <code>takeRight</code>, <code>takeRightWhile</code>,
<code>takeWhile</code>, <code>tap</code>, <code>throttle</code>, <code>thru</code>, <code>times</code>, <code>toArray</code>, <code>toPlainObject</code>,
<code>transform</code>, <code>union</code>, <code>uniq</code>, <code>unshift</code>, <code>unzip</code>, <code>unzipWith</code>, <code>values</code>,
<code>valuesIn</code>, <code>where</code>, <code>without</code>, <code>wrap</code>, <code>xor</code>, <code>zip</code>, <code>zipObject</code>, <code>zipWith</code>
<br>
<br>
The wrapper methods that are <strong>not</strong> chainable by default are:<br>
<code>add</code>, <code>attempt</code>, <code>camelCase</code>, <code>capitalize</code>, <code>ceil</code>, <code>clone</code>, <code>cloneDeep</code>,
<code>deburr</code>, <code>endsWith</code>, <code>escape</code>, <code>escapeRegExp</code>, <code>every</code>, <code>find</code>, <code>findIndex</code>,
<code>findKey</code>, <code>findLast</code>, <code>findLastIndex</code>, <code>findLastKey</code>, <code>findWhere</code>, <code>first</code>,
<code>floor</code>, <code>get</code>, <code>gt</code>, <code>gte</code>, <code>has</code>, <code>identity</code>, <code>includes</code>, <code>indexOf</code>,
<code>inRange</code>, <code>isArguments</code>, <code>isArray</code>, <code>isBoolean</code>, <code>isDate</code>, <code>isElement</code>,
<code>isEmpty</code>, <code>isEqual</code>, <code>isError</code>, <code>isFinite</code> <code>isFunction</code>, <code>isMatch</code>,
<code>isNative</code>, <code>isNaN</code>, <code>isNull</code>, <code>isNumber</code>, <code>isObject</code>, <code>isPlainObject</code>,
<code>isRegExp</code>, <code>isString</code>, <code>isUndefined</code>, <code>isTypedArray</code>, <code>join</code>, <code>kebabCase</code>,
<code>last</code>, <code>lastIndexOf</code>, <code>lt</code>, <code>lte</code>, <code>max</code>, <code>min</code>, <code>noConflict</code>, <code>noop</code>,
<code>now</code>, <code>pad</code>, <code>padLeft</code>, <code>padRight</code>, <code>parseInt</code>, <code>pop</code>, <code>random</code>, <code>reduce</code>,
<code>reduceRight</code>, <code>repeat</code>, <code>result</code>, <code>round</code>, <code>runInContext</code>, <code>shift</code>, <code>size</code>,
<code>snakeCase</code>, <code>some</code>, <code>sortedIndex</code>, <code>sortedLastIndex</code>, <code>startCase</code>,
<code>startsWith</code>, <code>sum</code>, <code>template</code>, <code>trim</code>, <code>trimLeft</code>, <code>trimRight</code>, <code>trunc</code>,
<code>unescape</code>, <code>uniqueId</code>, <code>value</code>, and <code>words</code>
<br>
<br>
The wrapper method <code>sample</code> will return a wrapped value when <code>n</code> is provided,
otherwise an unwrapped value is returned.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>value</code> <em>(*)</em>: The value to wrap in a <code>lodash</code> instance.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the new <code>lodash</code> wrapper instance.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> wrapped <span class="token operator">=</span> <span class="token function">_</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// returns an unwrapped value</span>
wrapped<span class="token punctuation">.</span><span class="token function">reduce</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span>total<span class="token punctuation">,</span> n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> total <span class="token operator">+</span> n<span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 6</span>

<span class="token comment" spellcheck="true">// returns a wrapped value</span>
<span class="token keyword">var</span> squares <span class="token operator">=</span> wrapped<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> n <span class="token operator">*</span> n<span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">isArray</span><span class="token punctuation">(</span>squares<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; false</span>

_<span class="token punctuation">.</span><span class="token function">isArray</span><span class="token punctuation">(</span>squares<span class="token punctuation">.</span><span class="token function">value</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_chainvalue-a-_-chain-value-"><a id="_chainvalue"></a><code>_.chain(value)</code></h3>
<p><a href="#_chainvalue">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6025" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a></p>
<p>Creates a <code>lodash</code> object that wraps <code>value</code> with explicit method
chaining enabled.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>value</code> <em>(*)</em>: The value to wrap.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the new <code>lodash</code> wrapper instance.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span>  <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>    <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'pebbles'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">1</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token keyword">var</span> youngest <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">chain</span><span class="token punctuation">(</span>users<span class="token punctuation">)</span>
  <span class="token punctuation">.</span><span class="token function">sortBy</span><span class="token punctuation">(</span><span class="token string">'age'</span><span class="token punctuation">)</span>
  <span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span>chr<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> chr<span class="token punctuation">.</span>user <span class="token operator">+</span> <span class="token string">' is '</span> <span class="token operator">+</span> chr<span class="token punctuation">.</span>age<span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
  <span class="token punctuation">.</span><span class="token function">first</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
  <span class="token punctuation">.</span><span class="token function">value</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'pebbles is 1'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_tapvalue-interceptor-thisarg-a-_-tap-value-interceptor-thisarg-"><a id="_tapvalue-interceptor-thisarg"></a><code>_.tap(value, interceptor, [thisArg])</code></h3>
<p><a href="#_tapvalue-interceptor-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6054" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a></p>
<p>This method invokes <code>interceptor</code> and returns <code>value</code>. The interceptor is
bound to <code>thisArg</code> and invoked with one argument; (value). The purpose of
this method is to "tap into" a method chain in order to perform operations
on intermediate results within the chain.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>value</code> <em>(*)</em>: The value to provide to <code>interceptor</code>.</li>
<li><code>interceptor</code> <em>(Function)</em>: The function to invoke.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>interceptor</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(*)</em>:  Returns <code>value</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token function">_</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
 <span class="token punctuation">.</span><span class="token function">tap</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span>array<span class="token punctuation">)</span> <span class="token punctuation">{</span>
   array<span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
 <span class="token punctuation">}</span><span class="token punctuation">)</span>
 <span class="token punctuation">.</span><span class="token function">reverse</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
 <span class="token punctuation">.</span><span class="token function">value</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [2, 1]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_thruvalue-interceptor-thisarg-a-_-thru-value-interceptor-thisarg-"><a id="_thruvalue-interceptor-thisarg"></a><code>_.thru(value, interceptor, [thisArg])</code></h3>
<p><a href="#_thruvalue-interceptor-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6080" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a></p>
<p>This method is like <code>_.tap</code> except that it returns the result of <code>interceptor</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>value</code> <em>(*)</em>: The value to provide to <code>interceptor</code>.</li>
<li><code>interceptor</code> <em>(Function)</em>: The function to invoke.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>interceptor</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(*)</em>:  Returns the result of <code>interceptor</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token function">_</span><span class="token punctuation">(</span><span class="token string">'  abc  '</span><span class="token punctuation">)</span>
 <span class="token punctuation">.</span><span class="token function">chain</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
 <span class="token punctuation">.</span><span class="token function">trim</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
 <span class="token punctuation">.</span><span class="token function">thru</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span>value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
   <span class="token keyword">return</span> <span class="token punctuation">[</span>value<span class="token punctuation">]</span><span class="token punctuation">;</span>
 <span class="token punctuation">}</span><span class="token punctuation">)</span>
 <span class="token punctuation">.</span><span class="token function">value</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['abc']</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_prototypechain-a-_-prototype-chain-"><a id="_prototypechain"></a><code>_.prototype.chain()</code></h3>
<p><a href="#_prototypechain">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6109" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a></p>
<p>Enables explicit method chaining on the wrapper object.</p>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the new <code>lodash</code> wrapper instance.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>   <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// without explicit chaining</span>
<span class="token function">_</span><span class="token punctuation">(</span>users<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">first</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'user': 'barney', 'age': 36 }</span>

<span class="token comment" spellcheck="true">// with explicit chaining</span>
<span class="token function">_</span><span class="token punctuation">(</span>users<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">chain</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
  <span class="token punctuation">.</span><span class="token function">first</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
  <span class="token punctuation">.</span><span class="token function">pick</span><span class="token punctuation">(</span><span class="token string">'user'</span><span class="token punctuation">)</span>
  <span class="token punctuation">.</span><span class="token function">value</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'user': 'barney' }</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_prototypecommit-a-_-prototype-commit-"><a id="_prototypecommit"></a><code>_.prototype.commit()</code></h3>
<p><a href="#_prototypecommit">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6138" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a></p>
<p>Executes the chained sequence and returns the wrapped result.</p>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the new <code>lodash</code> wrapper instance.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> array <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> wrapped <span class="token operator">=</span> <span class="token function">_</span><span class="token punctuation">(</span>array<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>array<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2]</span>

wrapped <span class="token operator">=</span> wrapped<span class="token punctuation">.</span><span class="token function">commit</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>array<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2, 3]</span>

wrapped<span class="token punctuation">.</span><span class="token function">last</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 3</span>

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>array<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2, 3]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_prototypeconcatvalues-a-_-prototype-concat-values-"><a id="_prototypeconcatvalues"></a><code>_.prototype.concat([values])</code></h3>
<p><a href="#_prototypeconcatvalues">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6162" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a></p>
<p>Creates a new array joining a wrapped array with any additional arrays
and/or values.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[values]</code> <em>(...*)</em>: The values to concatenate.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new concatenated array.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> array <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> wrapped <span class="token operator">=</span> <span class="token function">_</span><span class="token punctuation">(</span>array<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">concat</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>wrapped<span class="token punctuation">.</span><span class="token function">value</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2, 3, [4]]</span>

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>array<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_prototypeplant-a-_-prototype-plant-"><a id="_prototypeplant"></a><code>_.prototype.plant()</code></h3>
<p><a href="#_prototypeplant">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6192" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a></p>
<p>Creates a clone of the chained sequence planting <code>value</code> as the wrapped value.</p>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the new <code>lodash</code> wrapper instance.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> array <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> wrapped <span class="token operator">=</span> <span class="token function">_</span><span class="token punctuation">(</span>array<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span>value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> Math<span class="token punctuation">.</span><span class="token function">pow</span><span class="token punctuation">(</span>value<span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">var</span> other <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> otherWrapped <span class="token operator">=</span> wrapped<span class="token punctuation">.</span><span class="token function">plant</span><span class="token punctuation">(</span>other<span class="token punctuation">)</span><span class="token punctuation">;</span>

otherWrapped<span class="token punctuation">.</span><span class="token function">value</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [9, 16]</span>

wrapped<span class="token punctuation">.</span><span class="token function">value</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 4]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_prototypereverse-a-_-prototype-reverse-"><a id="_prototypereverse"></a><code>_.prototype.reverse()</code></h3>
<p><a href="#_prototypereverse">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6230" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a></p>
<p>Reverses the wrapped array so the first element becomes the last, the
second element becomes the second to last, and so on.
<br>
<br>
<strong>Note:</strong> This method mutates the wrapped array.</p>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the new reversed <code>lodash</code> wrapper instance.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> array <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token function">_</span><span class="token punctuation">(</span>array<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">reverse</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">value</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token comment" spellcheck="true">// =&gt; [3, 2, 1]</span>

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>array<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [3, 2, 1]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_prototypetostring-a-_-prototype-tostring-"><a id="_prototypetostring"></a><code>_.prototype.toString()</code></h3>
<p><a href="#_prototypetostring">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6260" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a></p>
<p>Produces the result of coercing the unwrapped value to a string.</p>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the coerced string value.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token function">_</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; '1,2,3'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_prototypevalue-a-_-prototype-value-"><a id="_prototypevalue"></a><code>_.prototype.value()</code></h3>
<p><a href="#_prototypevalue">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6277" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a></p>
<p>Executes the chained sequence to extract the unwrapped value.</p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em><em>.prototype.run, </em>.prototype.toJSON, _.prototype.valueOf</em></p>
<h4 id="-">返回值</h4>
<p><em>(*)</em>:  Returns the resolved unwrapped value.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token function">_</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">value</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2, 3]</span>
</code></pre>
<hr>
</div>
</div>
<div>
<h2 id="-collection-methods-"><code>“Collection” Methods</code></h2>
<div>
<h3 id="-a-id-_atcollection-props-a-_-at-collection-props-"><a id="_atcollection-props"></a><code>_.at(collection, [props])</code></h3>
<p><a href="#_atcollection-props">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6303" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.at" title="See the npm package">Ⓝ</a></p>
<p>Creates an array of elements corresponding to the given keys, or indexes,
of <code>collection</code>. Keys may be specified as individual arguments or as arrays
of keys.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>[props]</code> <em>(...(number|number[]|string|string[])</em>: The property names or indexes of elements to pick, specified individually or in arrays.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new array of picked elements.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">at</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">'a'</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">,</span> <span class="token string">'c'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['a', 'c']</span>

_<span class="token punctuation">.</span><span class="token function">at</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'fred'</span><span class="token punctuation">,</span> <span class="token string">'pebbles'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['barney', 'pebbles']</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_countbycollection-iteratee_identity-thisarg-a-_-countby-collection-iteratee-_-identity-thisarg-"><a id="_countbycollection-iteratee_identity-thisarg"></a><code>_.countBy(collection, [iteratee=_.identity], [thisArg])</code></h3>
<p><a href="#_countbycollection-iteratee_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6351" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.countby" title="See the npm package">Ⓝ</a></p>
<p>Creates an object composed of keys generated from the results of running
each element of <code>collection</code> through <code>iteratee</code>. The corresponding value
of each key is the number of times the key was returned by <code>iteratee</code>.
The <code>iteratee</code> is bound to <code>thisArg</code> and invoked with three arguments:<br>
(value, index|key, collection).
<br>
<br>
If a property name is provided for <code>iteratee</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>iteratee</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the composed aggregate object.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">countBy</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">4.3</span><span class="token punctuation">,</span> <span class="token number">6.1</span><span class="token punctuation">,</span> <span class="token number">6.4</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> Math<span class="token punctuation">.</span><span class="token function">floor</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { '4': 1, '6': 2 }</span>

_<span class="token punctuation">.</span><span class="token function">countBy</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">4.3</span><span class="token punctuation">,</span> <span class="token number">6.1</span><span class="token punctuation">,</span> <span class="token number">6.4</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">floor</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> Math<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { '4': 1, '6': 2 }</span>

_<span class="token punctuation">.</span><span class="token function">countBy</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">'one'</span><span class="token punctuation">,</span> <span class="token string">'two'</span><span class="token punctuation">,</span> <span class="token string">'three'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string">'length'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { '3': 2, '5': 1 }</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_everycollection-predicate_identity-thisarg-a-_-every-collection-predicate-_-identity-thisarg-"><a id="_everycollection-predicate_identity-thisarg"></a><code>_.every(collection, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_everycollection-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6403" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.every" title="See the npm package">Ⓝ</a></p>
<p>Checks if <code>predicate</code> returns truthy for <strong>all</strong> elements of <code>collection</code>.
The predicate is bound to <code>thisArg</code> and invoked with three arguments:<br>
(value, index|key, collection).
<br>
<br>
If a property name is provided for <code>predicate</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>predicate</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em>_.all</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>predicate</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(boolean)</em>:  Returns <code>true</code> if all elements pass the predicate check,
else <code>false</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">every</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token keyword">true</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token keyword">null</span><span class="token punctuation">,</span> <span class="token string">'yes'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> Boolean<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; false</span>

<span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>   <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// using the `_.matches` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">every</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; false</span>

<span class="token comment" spellcheck="true">// using the `_.matchesProperty` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">every</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">every</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; false</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_filtercollection-predicate_identity-thisarg-a-_-filter-collection-predicate-_-identity-thisarg-"><a id="_filtercollection-predicate_identity-thisarg"></a><code>_.filter(collection, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_filtercollection-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6463" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.filter" title="See the npm package">Ⓝ</a></p>
<p>Iterates over elements of <code>collection</code>, returning an array of all elements
<code>predicate</code> returns truthy for. The predicate is bound to <code>thisArg</code> and
invoked with three arguments: (value, index|key, collection).
<br>
<br>
If a property name is provided for <code>predicate</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>predicate</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em>_.select</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>predicate</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new filtered array.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">filter</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> n <span class="token operator">%</span> <span class="token number">2</span> <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [4, 6]</span>

<span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>   <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// using the `_.matches` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">filter</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['barney']</span>

<span class="token comment" spellcheck="true">// using the `_.matchesProperty` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">filter</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['fred']</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">filter</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['barney']</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_findcollection-predicate_identity-thisarg-a-_-find-collection-predicate-_-identity-thisarg-"><a id="_findcollection-predicate_identity-thisarg"></a><code>_.find(collection, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_findcollection-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6519" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.find" title="See the npm package">Ⓝ</a></p>
<p>Iterates over elements of <code>collection</code>, returning the first element
<code>predicate</code> returns truthy for. The predicate is bound to <code>thisArg</code> and
invoked with three arguments: (value, index|key, collection).
<br>
<br>
If a property name is provided for <code>predicate</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>predicate</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em>_.detect</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to search.</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>predicate</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(*)</em>:  Returns the matched element, else <code>undefined</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span>  <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>    <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'pebbles'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span>  <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">result</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">find</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>chr<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> chr<span class="token punctuation">.</span>age <span class="token operator">&lt;</span> <span class="token number">40</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'barney'</span>

<span class="token comment" spellcheck="true">// using the `_.matches` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">result</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">find</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'pebbles'</span>

<span class="token comment" spellcheck="true">// using the `_.matchesProperty` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">result</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">find</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'fred'</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">result</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">find</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'barney'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_findlastcollection-predicate_identity-thisarg-a-_-findlast-collection-predicate-_-identity-thisarg-"><a id="_findlastcollection-predicate_identity-thisarg"></a><code>_.findLast(collection, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_findlastcollection-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6540" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.findlast" title="See the npm package">Ⓝ</a></p>
<p>This method is like <code>_.find</code> except that it iterates over elements of
<code>collection</code> from right to left.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to search.</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>predicate</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(*)</em>:  Returns the matched element, else <code>undefined</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">findLast</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> n <span class="token operator">%</span> <span class="token number">2</span> <span class="token operator">==</span> <span class="token number">1</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 3</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_findwherecollection-source-a-_-findwhere-collection-source-"><a id="_findwherecollection-source"></a><code>_.findWhere(collection, source)</code></h3>
<p><a href="#_findwherecollection-source">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6571" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.findwhere" title="See the npm package">Ⓝ</a></p>
<p>Performs a deep comparison between each element in <code>collection</code> and the
source object, returning the first element that has equivalent property
values.
<br>
<br>
<strong>Note:</strong> This method supports comparing arrays, booleans, <code>Date</code> objects,
numbers, <code>Object</code> objects, regexes, and strings. Objects are compared by
their own, not inherited, enumerable properties. For comparing a single
own or inherited property value see <code>_.matchesProperty</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to search.</li>
<li><code>source</code> <em>(Object)</em>: The object of property values to match.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(*)</em>:  Returns the matched element, else <code>undefined</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>   <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">result</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">findWhere</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'barney'</span>

_<span class="token punctuation">.</span><span class="token function">result</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">findWhere</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'fred'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_foreachcollection-iteratee_identity-thisarg-a-_-foreach-collection-iteratee-_-identity-thisarg-"><a id="_foreachcollection-iteratee_identity-thisarg"></a><code>_.forEach(collection, [iteratee=_.identity], [thisArg])</code></h3>
<p><a href="#_foreachcollection-iteratee_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6605" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.foreach" title="See the npm package">Ⓝ</a></p>
<p>Iterates over elements of <code>collection</code> invoking <code>iteratee</code> for each element.
The <code>iteratee</code> is bound to <code>thisArg</code> and invoked with three arguments:<br>
(value, index|key, collection). Iteratee functions may exit iteration early
by explicitly returning <code>false</code>.
<br>
<br>
<strong>Note:</strong> As with other "Collections" methods, objects with a "length" property
are iterated like arrays. To avoid this behavior <code>_.forIn</code> or <code>_.forOwn</code>
may be used for object iteration.</p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em>_.each</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array|Object|string)</em>:  Returns <code>collection</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token function">_</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">forEach</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">value</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; logs each value from left to right and returns the array</span>

_<span class="token punctuation">.</span><span class="token function">forEach</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'a'</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">:</span> <span class="token number">2</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">,</span> key<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>n<span class="token punctuation">,</span> key<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; logs each value-key pair and returns the object (iteration order is not guaranteed)</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_foreachrightcollection-iteratee_identity-thisarg-a-_-foreachright-collection-iteratee-_-identity-thisarg-"><a id="_foreachrightcollection-iteratee_identity-thisarg"></a><code>_.forEachRight(collection, [iteratee=_.identity], [thisArg])</code></h3>
<p><a href="#_foreachrightcollection-iteratee_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6626" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.foreachright" title="See the npm package">Ⓝ</a></p>
<p>This method is like <code>_.forEach</code> except that it iterates over elements of
<code>collection</code> from right to left.</p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em>_.eachRight</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array|Object|string)</em>:  Returns <code>collection</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token function">_</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">forEachRight</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">value</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; logs each value from right to left and returns the array</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_groupbycollection-iteratee_identity-thisarg-a-_-groupby-collection-iteratee-_-identity-thisarg-"><a id="_groupbycollection-iteratee_identity-thisarg"></a><code>_.groupBy(collection, [iteratee=_.identity], [thisArg])</code></h3>
<p><a href="#_groupbycollection-iteratee_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6670" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.groupby" title="See the npm package">Ⓝ</a></p>
<p>Creates an object composed of keys generated from the results of running
each element of <code>collection</code> through <code>iteratee</code>. The corresponding value
of each key is an array of the elements responsible for generating the key.
The <code>iteratee</code> is bound to <code>thisArg</code> and invoked with three arguments:<br>
(value, index|key, collection).
<br>
<br>
If a property name is provided for <code>iteratee</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>iteratee</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the composed aggregate object.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">groupBy</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">4.2</span><span class="token punctuation">,</span> <span class="token number">6.1</span><span class="token punctuation">,</span> <span class="token number">6.4</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> Math<span class="token punctuation">.</span><span class="token function">floor</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { '4': [4.2], '6': [6.1, 6.4] }</span>

_<span class="token punctuation">.</span><span class="token function">groupBy</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">4.2</span><span class="token punctuation">,</span> <span class="token number">6.1</span><span class="token punctuation">,</span> <span class="token number">6.4</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">floor</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> Math<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { '4': [4.2], '6': [6.1, 6.4] }</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">groupBy</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">'one'</span><span class="token punctuation">,</span> <span class="token string">'two'</span><span class="token punctuation">,</span> <span class="token string">'three'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string">'length'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { '3': ['one', 'two'], '5': ['three'] }</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_includescollection-target-fromindex0-a-_-includes-collection-target-fromindex-0-"><a id="_includescollection-target-fromindex0"></a><code>_.includes(collection, target, [fromIndex=0])</code></h3>
<p><a href="#_includescollection-target-fromindex0">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6707" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.includes" title="See the npm package">Ⓝ</a></p>
<p>Checks if <code>target</code> is in <code>collection</code> using
<a href="http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero"><code>SameValueZero</code></a>
for equality comparisons. If <code>fromIndex</code> is negative, it's used as the offset
from the end of <code>collection</code>.</p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em><em>.contains, </em>.include</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to search.</li>
<li><code>target</code> <em>(*)</em>: The value to search for.</li>
<li><code>[fromIndex=0]</code> <em>(number)</em>: The index to search from.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(boolean)</em>:  Returns <code>true</code> if a matching element is found, else <code>false</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">includes</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>

_<span class="token punctuation">.</span><span class="token function">includes</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; false</span>

_<span class="token punctuation">.</span><span class="token function">includes</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token string">'fred'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>

_<span class="token punctuation">.</span><span class="token function">includes</span><span class="token punctuation">(</span><span class="token string">'pebbles'</span><span class="token punctuation">,</span> <span class="token string">'eb'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_indexbycollection-iteratee_identity-thisarg-a-_-indexby-collection-iteratee-_-identity-thisarg-"><a id="_indexbycollection-iteratee_identity-thisarg"></a><code>_.indexBy(collection, [iteratee=_.identity], [thisArg])</code></h3>
<p><a href="#_indexbycollection-iteratee_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6769" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.indexby" title="See the npm package">Ⓝ</a></p>
<p>Creates an object composed of keys generated from the results of running
each element of <code>collection</code> through <code>iteratee</code>. The corresponding value
of each key is the last element responsible for generating the key. The
iteratee function is bound to <code>thisArg</code> and invoked with three arguments:<br>
(value, index|key, collection).
<br>
<br>
If a property name is provided for <code>iteratee</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>iteratee</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the composed aggregate object.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> keyData <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'dir'</span><span class="token punctuation">:</span> <span class="token string">'left'</span><span class="token punctuation">,</span> <span class="token string">'code'</span><span class="token punctuation">:</span> <span class="token number">97</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'dir'</span><span class="token punctuation">:</span> <span class="token string">'right'</span><span class="token punctuation">,</span> <span class="token string">'code'</span><span class="token punctuation">:</span> <span class="token number">100</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">indexBy</span><span class="token punctuation">(</span>keyData<span class="token punctuation">,</span> <span class="token string">'dir'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }</span>

_<span class="token punctuation">.</span><span class="token function">indexBy</span><span class="token punctuation">(</span>keyData<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>object<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> String<span class="token punctuation">.</span><span class="token function">fromCharCode</span><span class="token punctuation">(</span>object<span class="token punctuation">.</span>code<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }</span>

_<span class="token punctuation">.</span><span class="token function">indexBy</span><span class="token punctuation">(</span>keyData<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>object<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">fromCharCode</span><span class="token punctuation">(</span>object<span class="token punctuation">.</span>code<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> String<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_invokecollection-path-args-a-_-invoke-collection-path-args-"><a id="_invokecollection-path-args"></a><code>_.invoke(collection, path, [args])</code></h3>
<p><a href="#_invokecollection-path-args">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6795" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.invoke" title="See the npm package">Ⓝ</a></p>
<p>Invokes the method at <code>path</code> of each element in <code>collection</code>, returning
an array of the results of each invoked method. Any additional arguments
are provided to each invoked method. If <code>methodName</code> is a function it's
invoked for, and <code>this</code> bound to, each element in <code>collection</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>path</code> <em>(Array|Function|string)</em>: The path of the method to invoke or the function invoked per iteration.</li>
<li><code>[args]</code> <em>(...*)</em>: The arguments to invoke the method with.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the array of results.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">invoke</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token punctuation">[</span><span class="token number">5</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">7</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string">'sort'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [[1, 5, 7], [1, 2, 3]]</span>

_<span class="token punctuation">.</span><span class="token function">invoke</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">123</span><span class="token punctuation">,</span> <span class="token number">456</span><span class="token punctuation">]</span><span class="token punctuation">,</span> String<span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>split<span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [['1', '2', '3'], ['4', '5', '6']]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_mapcollection-iteratee_identity-thisarg-a-_-map-collection-iteratee-_-identity-thisarg-"><a id="_mapcollection-iteratee_identity-thisarg"></a><code>_.map(collection, [iteratee=_.identity], [thisArg])</code></h3>
<p><a href="#_mapcollection-iteratee_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6864" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.map" title="See the npm package">Ⓝ</a></p>
<p>Creates an array of values by running each element in <code>collection</code> through
<code>iteratee</code>. The <code>iteratee</code> is bound to <code>thisArg</code> and invoked with three
arguments: (value, index|key, collection).
<br>
<br>
If a property name is provided for <code>iteratee</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>iteratee</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.
<br>
<br>
Many lodash methods are guarded to work as iteratees for methods like
<code>_.every</code>, <code>_.filter</code>, <code>_.map</code>, <code>_.mapValues</code>, <code>_.reject</code>, and <code>_.some</code>.
<br>
<br>
The guarded methods are:<br>
<code>ary</code>, <code>callback</code>, <code>chunk</code>, <code>clone</code>, <code>create</code>, <code>curry</code>, <code>curryRight</code>,
<code>drop</code>, <code>dropRight</code>, <code>every</code>, <code>fill</code>, <code>flatten</code>, <code>invert</code>, <code>max</code>, <code>min</code>,
<code>parseInt</code>, <code>slice</code>, <code>sortBy</code>, <code>take</code>, <code>takeRight</code>, <code>template</code>, <code>trim</code>,
<code>trimLeft</code>, <code>trimRight</code>, <code>trunc</code>, <code>random</code>, <code>range</code>, <code>sample</code>, <code>some</code>,
<code>sum</code>, <code>uniq</code>, and <code>words</code></p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em>_.collect</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new mapped array.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">function</span> <span class="token function">timesThree</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> n <span class="token operator">*</span> <span class="token number">3</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

_<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> timesThree<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [3, 6]</span>

_<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'a'</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">:</span> <span class="token number">2</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> timesThree<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [3, 6] (iteration order is not guaranteed)</span>

<span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['barney', 'fred']</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_partitioncollection-predicate_identity-thisarg-a-_-partition-collection-predicate-_-identity-thisarg-"><a id="_partitioncollection-predicate_identity-thisarg"></a><code>_.partition(collection, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_partitioncollection-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6929" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.partition" title="See the npm package">Ⓝ</a></p>
<p>Creates an array of elements split into two groups, the first of which
contains elements <code>predicate</code> returns truthy for, while the second of which
contains elements <code>predicate</code> returns falsey for. The predicate is bound
to <code>thisArg</code> and invoked with three arguments: (value, index|key, collection).
<br>
<br>
If a property name is provided for <code>predicate</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>predicate</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>predicate</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the array of grouped elements.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">partition</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> n <span class="token operator">%</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [[1, 3], [2]]</span>

_<span class="token punctuation">.</span><span class="token function">partition</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1.2</span><span class="token punctuation">,</span> <span class="token number">2.3</span><span class="token punctuation">,</span> <span class="token number">3.4</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">floor</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token operator">%</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> Math<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [[1.2, 3.4], [2.3]]</span>

<span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span>  <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>    <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'pebbles'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span>  <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token keyword">var</span> mapper <span class="token operator">=</span> <span class="token keyword">function</span><span class="token punctuation">(</span>array<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> _<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>array<span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// using the `_.matches` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">partition</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span> mapper<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [['pebbles'], ['barney', 'fred']]</span>

<span class="token comment" spellcheck="true">// using the `_.matchesProperty` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">partition</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">)</span><span class="token punctuation">,</span> mapper<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [['barney', 'pebbles'], ['fred']]</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">partition</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> mapper<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [['fred'], ['barney', 'pebbles']]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_pluckcollection-path-a-_-pluck-collection-path-"><a id="_pluckcollection-path"></a><code>_.pluck(collection, path)</code></h3>
<p><a href="#_pluckcollection-path">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6956" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.pluck" title="See the npm package">Ⓝ</a></p>
<p>Gets the property value of <code>path</code> from all elements in <code>collection</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>path</code> <em>(Array|string)</em>: The path of the property to pluck.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the property values.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>   <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['barney', 'fred']</span>

<span class="token keyword">var</span> userIndex <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">indexBy</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>userIndex<span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [36, 40] (iteration order is not guaranteed)</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_reducecollection-iteratee_identity-accumulator-thisarg-a-_-reduce-collection-iteratee-_-identity-accumulator-thisarg-"><a id="_reducecollection-iteratee_identity-accumulator-thisarg"></a><code>_.reduce(collection, [iteratee=_.identity], [accumulator], [thisArg])</code></h3>
<p><a href="#_reducecollection-iteratee_identity-accumulator-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6997" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.reduce" title="See the npm package">Ⓝ</a></p>
<p>Reduces <code>collection</code> to a value which is the accumulated result of running
each element in <code>collection</code> through <code>iteratee</code>, where each successive
invocation is supplied the return value of the previous. If <code>accumulator</code>
is not provided the first element of <code>collection</code> is used as the initial
value. The <code>iteratee</code> is bound to <code>thisArg</code> and invoked with four arguments:<br>
(accumulator, value, index|key, collection).
<br>
<br>
Many lodash methods are guarded to work as iteratees for methods like
<code>_.reduce</code>, <code>_.reduceRight</code>, and <code>_.transform</code>.
<br>
<br>
The guarded methods are:<br>
<code>assign</code>, <code>defaults</code>, <code>defaultsDeep</code>, <code>includes</code>, <code>merge</code>, <code>sortByAll</code>,
and <code>sortByOrder</code></p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em><em>.foldl, </em>.inject</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function)</em>: The function invoked per iteration.</li>
<li><code>[accumulator]</code> <em>(*)</em>: The initial value.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(*)</em>:  Returns the accumulated value.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">reduce</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>total<span class="token punctuation">,</span> n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> total <span class="token operator">+</span> n<span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 3</span>

_<span class="token punctuation">.</span><span class="token function">reduce</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'a'</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">:</span> <span class="token number">2</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>result<span class="token punctuation">,</span> n<span class="token punctuation">,</span> key<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  result<span class="token punctuation">[</span>key<span class="token punctuation">]</span> <span class="token operator">=</span> n <span class="token operator">*</span> <span class="token number">3</span><span class="token punctuation">;</span>
  <span class="token keyword">return</span> result<span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'a': 3, 'b': 6 } (iteration order is not guaranteed)</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_reducerightcollection-iteratee_identity-accumulator-thisarg-a-_-reduceright-collection-iteratee-_-identity-accumulator-thisarg-"><a id="_reducerightcollection-iteratee_identity-accumulator-thisarg"></a><code>_.reduceRight(collection, [iteratee=_.identity], [accumulator], [thisArg])</code></h3>
<p><a href="#_reducerightcollection-iteratee_identity-accumulator-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7021" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.reduceright" title="See the npm package">Ⓝ</a></p>
<p>This method is like <code>_.reduce</code> except that it iterates over elements of
<code>collection</code> from right to left.</p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em>_.foldr</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function)</em>: The function invoked per iteration.</li>
<li><code>[accumulator]</code> <em>(*)</em>: The initial value.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(*)</em>:  Returns the accumulated value.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> array <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">reduceRight</span><span class="token punctuation">(</span>array<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>flattened<span class="token punctuation">,</span> other<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> flattened<span class="token punctuation">.</span><span class="token function">concat</span><span class="token punctuation">(</span>other<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [4, 5, 2, 3, 0, 1]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_rejectcollection-predicate_identity-thisarg-a-_-reject-collection-predicate-_-identity-thisarg-"><a id="_rejectcollection-predicate_identity-thisarg"></a><code>_.reject(collection, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_rejectcollection-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7059" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.reject" title="See the npm package">Ⓝ</a></p>
<p>The opposite of <code>_.filter</code>; this method returns the elements of <code>collection</code>
that <code>predicate</code> does <strong>not</strong> return truthy for.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>predicate</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new filtered array.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">reject</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> n <span class="token operator">%</span> <span class="token number">2</span> <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 3]</span>

<span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>   <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// using the `_.matches` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">reject</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['barney']</span>

<span class="token comment" spellcheck="true">// using the `_.matchesProperty` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">reject</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['fred']</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">reject</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['barney']</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_samplecollection-n-a-_-sample-collection-n-"><a id="_samplecollection-n"></a><code>_.sample(collection, [n])</code></h3>
<p><a href="#_samplecollection-n">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7085" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.sample" title="See the npm package">Ⓝ</a></p>
<p>Gets a random element or <code>n</code> random elements from a collection.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to sample.</li>
<li><code>[n]</code> <em>(number)</em>: The number of elements to sample.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(*)</em>:  Returns the random sample(s).</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">sample</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 2</span>

_<span class="token punctuation">.</span><span class="token function">sample</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [3, 1]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_shufflecollection-a-_-shuffle-collection-"><a id="_shufflecollection"></a><code>_.shuffle(collection)</code></h3>
<p><a href="#_shufflecollection">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7122" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.shuffle" title="See the npm package">Ⓝ</a></p>
<p>Creates an array of shuffled values, using a version of the
<a href="https://en.wikipedia.org/wiki/Fisher-Yates_shuffle">Fisher-Yates shuffle</a>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to shuffle.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new shuffled array.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">shuffle</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [4, 1, 3, 2]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_sizecollection-a-_-size-collection-"><a id="_sizecollection"></a><code>_.size(collection)</code></h3>
<p><a href="#_sizecollection">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7146" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.size" title="See the npm package">Ⓝ</a></p>
<p>Gets the size of <code>collection</code> by returning its length for array-like
values or the number of own enumerable properties for objects.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to inspect.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(number)</em>:  Returns the size of <code>collection</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 3</span>

_<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'a'</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">:</span> <span class="token number">2</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 2</span>

_<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token string">'pebbles'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 7</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_somecollection-predicate_identity-thisarg-a-_-some-collection-predicate-_-identity-thisarg-"><a id="_somecollection-predicate_identity-thisarg"></a><code>_.some(collection, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_somecollection-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7200" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.some" title="See the npm package">Ⓝ</a></p>
<p>Checks if <code>predicate</code> returns truthy for <strong>any</strong> element of <code>collection</code>.
The function returns as soon as it finds a passing value and does not iterate
over the entire collection. The predicate is bound to <code>thisArg</code> and invoked
with three arguments: (value, index|key, collection).
<br>
<br>
If a property name is provided for <code>predicate</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>predicate</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em>_.any</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>predicate</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(boolean)</em>:  Returns <code>true</code> if any element passes the predicate check,
else <code>false</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">some</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token keyword">null</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token string">'yes'</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">]</span><span class="token punctuation">,</span> Boolean<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>

<span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>   <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// using the `_.matches` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">some</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; false</span>

<span class="token comment" spellcheck="true">// using the `_.matchesProperty` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">some</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">some</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_sortbycollection-iteratee_identity-thisarg-a-_-sortby-collection-iteratee-_-identity-thisarg-"><a id="_sortbycollection-iteratee_identity-thisarg"></a><code>_.sortBy(collection, [iteratee=_.identity], [thisArg])</code></h3>
<p><a href="#_sortbycollection-iteratee_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7259" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.sortby" title="See the npm package">Ⓝ</a></p>
<p>Creates an array of elements, sorted in ascending order by the results of
running each element in a collection through <code>iteratee</code>. This method performs
a stable sort, that is, it preserves the original sort order of equal elements.
The <code>iteratee</code> is bound to <code>thisArg</code> and invoked with three arguments:<br>
(value, index|key, collection).
<br>
<br>
If a property name is provided for <code>iteratee</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>iteratee</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new sorted array.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">sortBy</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> Math<span class="token punctuation">.</span><span class="token function">sin</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [3, 1, 2]</span>

_<span class="token punctuation">.</span><span class="token function">sortBy</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">sin</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> Math<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [3, 1, 2]</span>

<span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'pebbles'</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">sortBy</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['barney', 'fred', 'pebbles']</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_sortbyallcollection-iteratees-a-_-sortbyall-collection-iteratees-"><a id="_sortbyallcollection-iteratees"></a><code>_.sortByAll(collection, iteratees)</code></h3>
<p><a href="#_sortbyallcollection-iteratees">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7310" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.sortbyall" title="See the npm package">Ⓝ</a></p>
<p>This method is like <code>_.sortBy</code> except that it can sort by multiple iteratees
or property names.
<br>
<br>
If a property name is provided for an iteratee the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If an object is provided for an iteratee the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>iteratees</code> <em>(...(Function|Function[]|Object|Object[]|string|string[])</em>:  The iteratees to sort by, specified as individual values or arrays of values.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new sorted array.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>   <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">48</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>   <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">42</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">34</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">sortByAll</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string">'user'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">,</span> _<span class="token punctuation">.</span>values<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]]</span>

_<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">sortByAll</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>chr<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> Math<span class="token punctuation">.</span><span class="token function">floor</span><span class="token punctuation">(</span>chr<span class="token punctuation">.</span>age <span class="token operator">/</span> <span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span> _<span class="token punctuation">.</span>values<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_sortbyordercollection-iteratees-orders-a-_-sortbyorder-collection-iteratees-orders-"><a id="_sortbyordercollection-iteratees-orders"></a><code>_.sortByOrder(collection, iteratees, [orders])</code></h3>
<p><a href="#_sortbyordercollection-iteratees-orders">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7355" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.sortbyorder" title="See the npm package">Ⓝ</a></p>
<p>This method is like <code>_.sortByAll</code> except that it allows specifying the
sort orders of the iteratees to sort by. If <code>orders</code> is unspecified, all
values are sorted in ascending order. Otherwise, a value is sorted in
ascending order if its corresponding order is "asc", and descending if "desc".
<br>
<br>
If a property name is provided for an iteratee the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If an object is provided for an iteratee the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to iterate over.</li>
<li><code>iteratees</code> <em>(Function[]|Object[]|string[])</em>: The iteratees to sort by.</li>
<li><code>[orders]</code> <em>(boolean[])</em>: The sort orders of <code>iteratees</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new sorted array.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>   <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">48</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">34</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>   <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">42</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// sort by `user` in ascending order and by `age` in descending order</span>
_<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">sortByOrder</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string">'user'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string">'asc'</span><span class="token punctuation">,</span> <span class="token string">'desc'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">,</span> _<span class="token punctuation">.</span>values<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_wherecollection-source-a-_-where-collection-source-"><a id="_wherecollection-source"></a><code>_.where(collection, source)</code></h3>
<p><a href="#_wherecollection-source">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7400" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.where" title="See the npm package">Ⓝ</a></p>
<p>Performs a deep comparison between each element in <code>collection</code> and the
source object, returning an array of all elements that have equivalent
property values.
<br>
<br>
<strong>Note:</strong> This method supports comparing arrays, booleans, <code>Date</code> objects,
numbers, <code>Object</code> objects, regexes, and strings. Objects are compared by
their own, not inherited, enumerable properties. For comparing a single
own or inherited property value see <code>_.matchesProperty</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>collection</code> <em>(Array|Object|string)</em>: The collection to search.</li>
<li><code>source</code> <em>(Object)</em>: The object of property values to match.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new filtered array.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span><span class="token punctuation">,</span> <span class="token string">'pets'</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'hoppy'</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>   <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span><span class="token punctuation">,</span> <span class="token string">'pets'</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'baby puss'</span><span class="token punctuation">,</span> <span class="token string">'dino'</span><span class="token punctuation">]</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">where</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['barney']</span>

_<span class="token punctuation">.</span><span class="token function">pluck</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">where</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'pets'</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'dino'</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['fred']</span>
</code></pre>
<hr>
</div>
</div>
<div>
<h2 id="-object-methods-"><code>“Object” Methods</code></h2>
<div>
<h3 id="-a-id-_assignobject-sources-customizer-thisarg-a-_-assign-object-sources-customizer-thisarg-"><a id="_assignobject-sources-customizer-thisarg"></a><code>_.assign(object, [sources], [customizer], [thisArg])</code></h3>
<p><a href="#_assignobject-sources-customizer-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9372" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.assign" title="See the npm package">Ⓝ</a></p>
<p>Assigns own enumerable properties of source object(s) to the destination
object. Subsequent sources overwrite property assignments of previous sources.
If <code>customizer</code> is provided it's invoked to produce the assigned values.
The <code>customizer</code> is bound to <code>thisArg</code> and invoked with five arguments:<br>
(objectValue, sourceValue, key, object, source).
<br>
<br>
<strong>Note:</strong> This method mutates <code>object</code> and is based on
<a href="http://ecma-international.org/ecma-262/6.0/#sec-object.assign"><code>Object.assign</code></a>.</p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em>_.extend</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The destination object.</li>
<li><code>[sources]</code> <em>(...Object)</em>: The source objects.</li>
<li><code>[customizer]</code> <em>(Function)</em>: The function to customize assigned values.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>customizer</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns <code>object</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">assign</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'user': 'fred', 'age': 40 }</span>

<span class="token comment" spellcheck="true">// using a customizer callback</span>
<span class="token keyword">var</span> defaults <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">partialRight</span><span class="token punctuation">(</span>_<span class="token punctuation">.</span>assign<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>value<span class="token punctuation">,</span> other<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> _<span class="token punctuation">.</span><span class="token function">isUndefined</span><span class="token punctuation">(</span>value<span class="token punctuation">)</span> <span class="token operator">?</span> other <span class="token punctuation">:</span> value<span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token function">defaults</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'user': 'barney', 'age': 36 }</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_createprototype-properties-a-_-create-prototype-properties-"><a id="_createprototype-properties"></a><code>_.create(prototype, [properties])</code></h3>
<p><a href="#_createprototype-properties">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9412" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.create" title="See the npm package">Ⓝ</a></p>
<p>Creates an object that inherits from the given <code>prototype</code> object. If a
<code>properties</code> object is provided its own enumerable properties are assigned
to the created object.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>prototype</code> <em>(Object)</em>: The object to inherit from.</li>
<li><code>[properties]</code> <em>(Object)</em>: The properties to assign to the object.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the new object.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">function</span> <span class="token function">Shape</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>x <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>y <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">function</span> <span class="token function">Circle</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  Shape<span class="token punctuation">.</span><span class="token function">call</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

Circle<span class="token punctuation">.</span>prototype <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">create</span><span class="token punctuation">(</span>Shape<span class="token punctuation">.</span>prototype<span class="token punctuation">,</span> <span class="token punctuation">{</span>
  <span class="token string">'constructor'</span><span class="token punctuation">:</span> Circle
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">var</span> circle <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Circle</span><span class="token punctuation">;</span>
circle <span class="token keyword">instanceof</span> <span class="token class-name">Circle</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>

circle <span class="token keyword">instanceof</span> <span class="token class-name">Shape</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_defaultsobject-sources-a-_-defaults-object-sources-"><a id="_defaultsobject-sources"></a><code>_.defaults(object, [sources])</code></h3>
<p><a href="#_defaultsobject-sources">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9438" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.defaults" title="See the npm package">Ⓝ</a></p>
<p>Assigns own enumerable properties of source object(s) to the destination
object for all destination properties that resolve to <code>undefined</code>. Once a
property is set, additional values of the same property are ignored.
<br>
<br>
<strong>Note:</strong> This method mutates <code>object</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The destination object.</li>
<li><code>[sources]</code> <em>(...Object)</em>: The source objects.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns <code>object</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">defaults</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'user': 'barney', 'age': 36 }</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_defaultsdeepobject-sources-a-_-defaultsdeep-object-sources-"><a id="_defaultsdeepobject-sources"></a><code>_.defaultsDeep(object, [sources])</code></h3>
<p><a href="#_defaultsdeepobject-sources">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9458" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.defaultsdeep" title="See the npm package">Ⓝ</a></p>
<p>This method is like <code>_.defaults</code> except that it recursively assigns
default properties.
<br>
<br>
<strong>Note:</strong> This method mutates <code>object</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The destination object.</li>
<li><code>[sources]</code> <em>(...Object)</em>: The source objects.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns <code>object</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">defaultsDeep</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token string">'name'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token string">'name'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'user': { 'name': 'barney', 'age': 36 } }</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_findkeyobject-predicate_identity-thisarg-a-_-findkey-object-predicate-_-identity-thisarg-"><a id="_findkeyobject-predicate_identity-thisarg"></a><code>_.findKey(object, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_findkeyobject-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9508" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.findkey" title="See the npm package">Ⓝ</a></p>
<p>This method is like <code>_.find</code> except that it returns the key of the first
element <code>predicate</code> returns truthy for instead of the element itself.
<br>
<br>
If a property name is provided for <code>predicate</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>predicate</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to search.</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>predicate</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string|undefined)</em>:  Returns the key of the matched element, else <code>undefined</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">{</span>
  <span class="token string">'barney'</span><span class="token punctuation">:</span>  <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token string">'fred'</span><span class="token punctuation">:</span>    <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token string">'pebbles'</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span>  <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">findKey</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>chr<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> chr<span class="token punctuation">.</span>age <span class="token operator">&lt;</span> <span class="token number">40</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'barney' (iteration order is not guaranteed)</span>

<span class="token comment" spellcheck="true">// using the `_.matches` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">findKey</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'pebbles'</span>

<span class="token comment" spellcheck="true">// using the `_.matchesProperty` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">findKey</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'fred'</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">findKey</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'barney'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_findlastkeyobject-predicate_identity-thisarg-a-_-findlastkey-object-predicate-_-identity-thisarg-"><a id="_findlastkeyobject-predicate_identity-thisarg"></a><code>_.findLastKey(object, [predicate=_.identity], [thisArg])</code></h3>
<p><a href="#_findlastkeyobject-predicate_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9558" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.findlastkey" title="See the npm package">Ⓝ</a></p>
<p>This method is like <code>_.findKey</code> except that it iterates over elements of
a collection in the opposite order.
<br>
<br>
If a property name is provided for <code>predicate</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>predicate</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to search.</li>
<li><code>[predicate=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>predicate</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string|undefined)</em>:  Returns the key of the matched element, else <code>undefined</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">{</span>
  <span class="token string">'barney'</span><span class="token punctuation">:</span>  <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token string">'fred'</span><span class="token punctuation">:</span>    <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token string">'pebbles'</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span>  <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">findLastKey</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>chr<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> chr<span class="token punctuation">.</span>age <span class="token operator">&lt;</span> <span class="token number">40</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; returns `pebbles` assuming `_.findKey` returns `barney`</span>

<span class="token comment" spellcheck="true">// using the `_.matches` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">findLastKey</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span><span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">:</span> <span class="token keyword">true</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'barney'</span>

<span class="token comment" spellcheck="true">// using the `_.matchesProperty` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">findLastKey</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">,</span> <span class="token keyword">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'fred'</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">findLastKey</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'active'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'pebbles'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_forinobject-iteratee_identity-thisarg-a-_-forin-object-iteratee-_-identity-thisarg-"><a id="_forinobject-iteratee_identity-thisarg"></a><code>_.forIn(object, [iteratee=_.identity], [thisArg])</code></h3>
<p><a href="#_forinobject-iteratee_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9587" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.forin" title="See the npm package">Ⓝ</a></p>
<p>Iterates over own and inherited enumerable properties of an object invoking
<code>iteratee</code> for each property. The <code>iteratee</code> is bound to <code>thisArg</code> and invoked
with three arguments: (value, key, object). Iteratee functions may exit
iteration early by explicitly returning <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns <code>object</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">function</span> <span class="token function">Foo</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>a <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>b <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

Foo<span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>c <span class="token operator">=</span> <span class="token number">3</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">forIn</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Foo</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>value<span class="token punctuation">,</span> key<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>key<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; logs 'a', 'b', and 'c' (iteration order is not guaranteed)</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_forinrightobject-iteratee_identity-thisarg-a-_-forinright-object-iteratee-_-identity-thisarg-"><a id="_forinrightobject-iteratee_identity-thisarg"></a><code>_.forInRight(object, [iteratee=_.identity], [thisArg])</code></h3>
<p><a href="#_forinrightobject-iteratee_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9614" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.forinright" title="See the npm package">Ⓝ</a></p>
<p>This method is like <code>_.forIn</code> except that it iterates over properties of
<code>object</code> in the opposite order.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns <code>object</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">function</span> <span class="token function">Foo</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>a <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>b <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

Foo<span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>c <span class="token operator">=</span> <span class="token number">3</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">forInRight</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Foo</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>value<span class="token punctuation">,</span> key<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>key<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; logs 'c', 'b', and 'a' assuming `_.forIn ` logs 'a', 'b', and 'c'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_forownobject-iteratee_identity-thisarg-a-_-forown-object-iteratee-_-identity-thisarg-"><a id="_forownobject-iteratee_identity-thisarg"></a><code>_.forOwn(object, [iteratee=_.identity], [thisArg])</code></h3>
<p><a href="#_forownobject-iteratee_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9643" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.forown" title="See the npm package">Ⓝ</a></p>
<p>Iterates over own enumerable properties of an object invoking <code>iteratee</code>
for each property. The <code>iteratee</code> is bound to <code>thisArg</code> and invoked with
three arguments: (value, key, object). Iteratee functions may exit iteration
early by explicitly returning <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns <code>object</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">function</span> <span class="token function">Foo</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>a <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>b <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

Foo<span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>c <span class="token operator">=</span> <span class="token number">3</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">forOwn</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Foo</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>value<span class="token punctuation">,</span> key<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>key<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; logs 'a' and 'b' (iteration order is not guaranteed)</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_forownrightobject-iteratee_identity-thisarg-a-_-forownright-object-iteratee-_-identity-thisarg-"><a id="_forownrightobject-iteratee_identity-thisarg"></a><code>_.forOwnRight(object, [iteratee=_.identity], [thisArg])</code></h3>
<p><a href="#_forownrightobject-iteratee_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9670" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.forownright" title="See the npm package">Ⓝ</a></p>
<p>This method is like <code>_.forOwn</code> except that it iterates over properties of
<code>object</code> in the opposite order.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns <code>object</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">function</span> <span class="token function">Foo</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>a <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>b <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

Foo<span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>c <span class="token operator">=</span> <span class="token number">3</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">forOwnRight</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Foo</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>value<span class="token punctuation">,</span> key<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>key<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; logs 'b' and 'a' assuming `_.forOwn` logs 'a' and 'b'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_functionsobject-a-_-functions-object-"><a id="_functionsobject"></a><code>_.functions(object)</code></h3>
<p><a href="#_functionsobject">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9687" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.functions" title="See the npm package">Ⓝ</a></p>
<p>Creates an array of function property names from all enumerable properties,
own and inherited, of <code>object</code>.</p>
<h4 id="-aliases-">别名（Aliases）</h4>
<p><em>_.methods</em></p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to inspect.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new array of property names.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">functions</span><span class="token punctuation">(</span>_<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['after', 'ary', 'assign', ...]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_getobject-path-defaultvalue-a-_-get-object-path-defaultvalue-"><a id="_getobject-path-defaultvalue"></a><code>_.get(object, path, [defaultValue])</code></h3>
<p><a href="#_getobject-path-defaultvalue">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9715" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.get" title="See the npm package">Ⓝ</a></p>
<p>Gets the property value at <code>path</code> of <code>object</code>. If the resolved value is
<code>undefined</code> the <code>defaultValue</code> is used in its place.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to query.</li>
<li><code>path</code> <em>(Array|string)</em>: The path of the property to get.</li>
<li><code>[defaultValue]</code> <em>(*)</em>: The value returned if the resolved value is <code>undefined</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(*)</em>:  Returns the resolved value.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> object <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token string">'a'</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span> <span class="token string">'b'</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token string">'c'</span><span class="token punctuation">:</span> <span class="token number">3</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token keyword">get</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> <span class="token string">'a[0].b.c'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 3</span>

_<span class="token punctuation">.</span><span class="token keyword">get</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string">'a'</span><span class="token punctuation">,</span> <span class="token string">'0'</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">,</span> <span class="token string">'c'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 3</span>

_<span class="token punctuation">.</span><span class="token keyword">get</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> <span class="token string">'a.b.c'</span><span class="token punctuation">,</span> <span class="token string">'default'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'default'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_hasobject-path-a-_-has-object-path-"><a id="_hasobject-path"></a><code>_.has(object, path)</code></h3>
<p><a href="#_hasobject-path">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9742" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.has" title="See the npm package">Ⓝ</a></p>
<p>Checks if <code>path</code> is a direct property.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to query.</li>
<li><code>path</code> <em>(Array|string)</em>: The path to check.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(boolean)</em>:  Returns <code>true</code> if <code>path</code> is a direct property, else <code>false</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> object <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token string">'a'</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token string">'b'</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token string">'c'</span><span class="token punctuation">:</span> <span class="token number">3</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">has</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> <span class="token string">'a'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>

_<span class="token punctuation">.</span><span class="token function">has</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> <span class="token string">'a.b.c'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>

_<span class="token punctuation">.</span><span class="token function">has</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string">'a'</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">,</span> <span class="token string">'c'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_invertobject-multivalue-a-_-invert-object-multivalue-"><a id="_invertobject-multivalue"></a><code>_.invert(object, [multiValue])</code></h3>
<p><a href="#_invertobject-multivalue">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9783" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.invert" title="See the npm package">Ⓝ</a></p>
<p>Creates an object composed of the inverted keys and values of <code>object</code>.
If <code>object</code> contains duplicate values, subsequent values overwrite property
assignments of previous values unless <code>multiValue</code> is <code>true</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to invert.</li>
<li><code>[multiValue]</code> <em>(boolean)</em>: Allow multiple values per key.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the new inverted object.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> object <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token string">'a'</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">:</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token string">'c'</span><span class="token punctuation">:</span> <span class="token number">1</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">invert</span><span class="token punctuation">(</span>object<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { '1': 'c', '2': 'b' }</span>

<span class="token comment" spellcheck="true">// with `multiValue`</span>
_<span class="token punctuation">.</span><span class="token function">invert</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> <span class="token keyword">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { '1': ['a', 'c'], '2': ['b'] }</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_keysobject-a-_-keys-object-"><a id="_keysobject"></a><code>_.keys(object)</code></h3>
<p><a href="#_keysobject">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9837" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.keys" title="See the npm package">Ⓝ</a></p>
<p>Creates an array of the own enumerable property names of <code>object</code>.
<br>
<br>
<strong>Note:</strong> Non-object values are coerced to objects. See the
<a href="http://ecma-international.org/ecma-262/6.0/#sec-object.keys">ES spec</a>
for more details.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to query.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the array of property names.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">function</span> <span class="token function">Foo</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>a <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>b <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

Foo<span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>c <span class="token operator">=</span> <span class="token number">3</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">keys</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Foo</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['a', 'b'] (iteration order is not guaranteed)</span>

_<span class="token punctuation">.</span><span class="token function">keys</span><span class="token punctuation">(</span><span class="token string">'hi'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['0', '1']</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_keysinobject-a-_-keysin-object-"><a id="_keysinobject"></a><code>_.keysIn(object)</code></h3>
<p><a href="#_keysinobject">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9868" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.keysin" title="See the npm package">Ⓝ</a></p>
<p>Creates an array of the own and inherited enumerable property names of <code>object</code>.
<br>
<br>
<strong>Note:</strong> Non-object values are coerced to objects.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to query.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the array of property names.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">function</span> <span class="token function">Foo</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>a <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>b <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

Foo<span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>c <span class="token operator">=</span> <span class="token number">3</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">keysIn</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Foo</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['a', 'b', 'c'] (iteration order is not guaranteed)</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_mapkeysobject-iteratee_identity-thisarg-a-_-mapkeys-object-iteratee-_-identity-thisarg-"><a id="_mapkeysobject-iteratee_identity-thisarg"></a><code>_.mapKeys(object, [iteratee=_.identity], [thisArg])</code></h3>
<p><a href="#_mapkeysobject-iteratee_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9945" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.mapkeys" title="See the npm package">Ⓝ</a></p>
<p>The opposite of <code>_.mapValues</code>; this method creates an object with the
same values as <code>object</code> and keys generated by running each own enumerable
property of <code>object</code> through <code>iteratee</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the new mapped object.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">mapKeys</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'a'</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">:</span> <span class="token number">2</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>value<span class="token punctuation">,</span> key<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> key <span class="token operator">+</span> value<span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'a1': 1, 'b2': 2 }</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_mapvaluesobject-iteratee_identity-thisarg-a-_-mapvalues-object-iteratee-_-identity-thisarg-"><a id="_mapvaluesobject-iteratee_identity-thisarg"></a><code>_.mapValues(object, [iteratee=_.identity], [thisArg])</code></h3>
<p><a href="#_mapvaluesobject-iteratee_identity-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9988" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.mapvalues" title="See the npm package">Ⓝ</a></p>
<p>Creates an object with the same keys as <code>object</code> and values generated by
running each own enumerable property of <code>object</code> through <code>iteratee</code>. The
iteratee function is bound to <code>thisArg</code> and invoked with three arguments:<br>
(value, key, object).
<br>
<br>
If a property name is provided for <code>iteratee</code> the created <code>_.property</code>
style callback returns the property value of the given element.
<br>
<br>
If a value is also provided for <code>thisArg</code> the created <code>_.matchesProperty</code>
style callback returns <code>true</code> for elements that have a matching property
value, else <code>false</code>.
<br>
<br>
If an object is provided for <code>iteratee</code> the created <code>_.matches</code> style
callback returns <code>true</code> for elements that have the properties of the given
object, else <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function|Object|string)</em>: The function invoked per iteration.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the new mapped object.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">mapValues</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'a'</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">:</span> <span class="token number">2</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> n <span class="token operator">*</span> <span class="token number">3</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'a': 3, 'b': 6 }</span>

<span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">{</span>
  <span class="token string">'fred'</span><span class="token punctuation">:</span>    <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span>    <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token string">'pebbles'</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'pebbles'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">1</span> <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// using the `_.property` callback shorthand</span>
_<span class="token punctuation">.</span><span class="token function">mapValues</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_mergeobject-sources-customizer-thisarg-a-_-merge-object-sources-customizer-thisarg-"><a id="_mergeobject-sources-customizer-thisarg"></a><code>_.merge(object, [sources], [customizer], [thisArg])</code></h3>
<p><a href="#_mergeobject-sources-customizer-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9338" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.merge" title="See the npm package">Ⓝ</a></p>
<p>Recursively merges own enumerable properties of the source object(s), that
don't resolve to <code>undefined</code> into the destination object. Subsequent sources
overwrite property assignments of previous sources. If <code>customizer</code> is
provided it's invoked to produce the merged values of the destination and
source properties. If <code>customizer</code> returns <code>undefined</code> merging is handled
by the method instead. The <code>customizer</code> is bound to <code>thisArg</code> and invoked
with five arguments: (objectValue, sourceValue, key, object, source).</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The destination object.</li>
<li><code>[sources]</code> <em>(...Object)</em>: The source objects.</li>
<li><code>[customizer]</code> <em>(Function)</em>: The function to customize assigned values.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>customizer</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns <code>object</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> users <span class="token operator">=</span> <span class="token punctuation">{</span>
  <span class="token string">'data'</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span> <span class="token punctuation">}</span><span class="token punctuation">]</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>

<span class="token keyword">var</span> ages <span class="token operator">=</span> <span class="token punctuation">{</span>
  <span class="token string">'data'</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">36</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span> <span class="token punctuation">}</span><span class="token punctuation">]</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">merge</span><span class="token punctuation">(</span>users<span class="token punctuation">,</span> ages<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }</span>

<span class="token comment" spellcheck="true">// using a customizer callback</span>
<span class="token keyword">var</span> object <span class="token operator">=</span> <span class="token punctuation">{</span>
  <span class="token string">'fruits'</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'apple'</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token string">'vegetables'</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'beet'</span><span class="token punctuation">]</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>

<span class="token keyword">var</span> other <span class="token operator">=</span> <span class="token punctuation">{</span>
  <span class="token string">'fruits'</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'banana'</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token string">'vegetables'</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'carrot'</span><span class="token punctuation">]</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">merge</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> other<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>a<span class="token punctuation">,</span> b<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">if</span> <span class="token punctuation">(</span>_<span class="token punctuation">.</span><span class="token function">isArray</span><span class="token punctuation">(</span>a<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> a<span class="token punctuation">.</span><span class="token function">concat</span><span class="token punctuation">(</span>b<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_omitobject-predicate-thisarg-a-_-omit-object-predicate-thisarg-"><a id="_omitobject-predicate-thisarg"></a><code>_.omit(object, [predicate], [thisArg])</code></h3>
<p><a href="#_omitobject-predicate-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10013" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.omit" title="See the npm package">Ⓝ</a></p>
<p>The opposite of <code>_.pick</code>; this method creates an object composed of the
own and inherited enumerable properties of <code>object</code> that are not omitted.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The source object.</li>
<li><code>[predicate]</code> <em>(Function|...(string|string[])</em>: The function invoked per iteration or property names to omit, specified as individual property names or arrays of property names.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>predicate</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the new object.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> object <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">omit</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'user': 'fred' }</span>

_<span class="token punctuation">.</span><span class="token function">omit</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> _<span class="token punctuation">.</span>isNumber<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'user': 'fred' }</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_pairsobject-a-_-pairs-object-"><a id="_pairsobject"></a><code>_.pairs(object)</code></h3>
<p><a href="#_pairsobject">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10041" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.pairs" title="See the npm package">Ⓝ</a></p>
<p>Creates a two dimensional array of the key-value pairs for <code>object</code>,
e.g. <code>[[key1, value1], [key2, value2]]</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to query.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the new array of key-value pairs.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">pairs</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'barney'</span><span class="token punctuation">:</span> <span class="token number">36</span><span class="token punctuation">,</span> <span class="token string">'fred'</span><span class="token punctuation">:</span> <span class="token number">40</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_pickobject-predicate-thisarg-a-_-pick-object-predicate-thisarg-"><a id="_pickobject-predicate-thisarg"></a><code>_.pick(object, [predicate], [thisArg])</code></h3>
<p><a href="#_pickobject-predicate-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10082" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.pick" title="See the npm package">Ⓝ</a></p>
<p>Creates an object composed of the picked <code>object</code> properties. Property
names may be specified as individual arguments or as arrays of property
names. If <code>predicate</code> is provided it's invoked for each property of <code>object</code>
picking the properties <code>predicate</code> returns truthy for. The predicate is
bound to <code>thisArg</code> and invoked with three arguments: (value, key, object).</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The source object.</li>
<li><code>[predicate]</code> <em>(Function|...(string|string[])</em>: The function invoked per iteration or property names to pick, specified as individual property names or arrays of property names.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>predicate</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns the new object.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> object <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span><span class="token punctuation">,</span> <span class="token string">'age'</span><span class="token punctuation">:</span> <span class="token number">40</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">pick</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> <span class="token string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'user': 'fred' }</span>

_<span class="token punctuation">.</span><span class="token function">pick</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> _<span class="token punctuation">.</span>isString<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'user': 'fred' }</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_resultobject-path-defaultvalue-a-_-result-object-path-defaultvalue-"><a id="_resultobject-path-defaultvalue"></a><code>_.result(object, path, [defaultValue])</code></h3>
<p><a href="#_resultobject-path-defaultvalue">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10119" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.result" title="See the npm package">Ⓝ</a></p>
<p>This method is like <code>_.get</code> except that if the resolved value is a function
it's invoked with the <code>this</code> binding of its parent object and its result
is returned.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to query.</li>
<li><code>path</code> <em>(Array|string)</em>: The path of the property to resolve.</li>
<li><code>[defaultValue]</code> <em>(*)</em>: The value returned if the resolved value is <code>undefined</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(*)</em>:  Returns the resolved value.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> object <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token string">'a'</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span> <span class="token string">'b'</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token string">'c1'</span><span class="token punctuation">:</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token string">'c2'</span><span class="token punctuation">:</span> _<span class="token punctuation">.</span><span class="token function">constant</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">result</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> <span class="token string">'a[0].b.c1'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 3</span>

_<span class="token punctuation">.</span><span class="token function">result</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> <span class="token string">'a[0].b.c2'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 4</span>

_<span class="token punctuation">.</span><span class="token function">result</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> <span class="token string">'a.b.c'</span><span class="token punctuation">,</span> <span class="token string">'default'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'default'</span>

_<span class="token punctuation">.</span><span class="token function">result</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> <span class="token string">'a.b.c'</span><span class="token punctuation">,</span> _<span class="token punctuation">.</span><span class="token function">constant</span><span class="token punctuation">(</span><span class="token string">'default'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'default'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_setobject-path-value-a-_-set-object-path-value-"><a id="_setobject-path-value"></a><code>_.set(object, path, value)</code></h3>
<p><a href="#_setobject-path-value">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10155" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.set" title="See the npm package">Ⓝ</a></p>
<p>Sets the property value of <code>path</code> on <code>object</code>. If a portion of <code>path</code>
does not exist it's created.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to augment.</li>
<li><code>path</code> <em>(Array|string)</em>: The path of the property to set.</li>
<li><code>value</code> <em>(*)</em>: The value to set.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Object)</em>:  Returns <code>object</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">var</span> object <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token string">'a'</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span> <span class="token string">'b'</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token string">'c'</span><span class="token punctuation">:</span> <span class="token number">3</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token keyword">set</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> <span class="token string">'a[0].b.c'</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>object<span class="token punctuation">.</span>a<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>b<span class="token punctuation">.</span>c<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 4</span>

_<span class="token punctuation">.</span><span class="token keyword">set</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span> <span class="token string">'x[0].y.z'</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>object<span class="token punctuation">.</span>x<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>y<span class="token punctuation">.</span>z<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 5</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_transformobject-iteratee_identity-accumulator-thisarg-a-_-transform-object-iteratee-_-identity-accumulator-thisarg-"><a id="_transformobject-iteratee_identity-accumulator-thisarg"></a><code>_.transform(object, [iteratee=_.identity], [accumulator], [thisArg])</code></h3>
<p><a href="#_transformobject-iteratee_identity-accumulator-thisarg">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10210" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.transform" title="See the npm package">Ⓝ</a></p>
<p>An alternative to <code>_.reduce</code>; this method transforms <code>object</code> to a new
<code>accumulator</code> object which is the result of running each of its own enumerable
properties through <code>iteratee</code>, with each invocation potentially mutating
the <code>accumulator</code> object. The <code>iteratee</code> is bound to <code>thisArg</code> and invoked
with four arguments: (accumulator, value, key, object). Iteratee functions
may exit iteration early by explicitly returning <code>false</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Array|Object)</em>: The object to iterate over.</li>
<li><code>[iteratee=_.identity]</code> <em>(Function)</em>: The function invoked per iteration.</li>
<li><code>[accumulator]</code> <em>(*)</em>: The custom accumulator value.</li>
<li><code>[thisArg]</code> <em>(*)</em>: The <code>this</code> binding of <code>iteratee</code>.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(*)</em>:  Returns the accumulated value.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">transform</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>result<span class="token punctuation">,</span> n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  result<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span>n <span class="token operator">*</span><span class="token operator">=</span> n<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token keyword">return</span> n <span class="token operator">%</span> <span class="token number">2</span> <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [4, 9]</span>

_<span class="token punctuation">.</span><span class="token function">transform</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'a'</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">:</span> <span class="token number">2</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>result<span class="token punctuation">,</span> n<span class="token punctuation">,</span> key<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  result<span class="token punctuation">[</span>key<span class="token punctuation">]</span> <span class="token operator">=</span> n <span class="token operator">*</span> <span class="token number">3</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; { 'a': 3, 'b': 6 }</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_valuesobject-a-_-values-object-"><a id="_valuesobject"></a><code>_.values(object)</code></h3>
<p><a href="#_valuesobject">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10257" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.values" title="See the npm package">Ⓝ</a></p>
<p>Creates an array of the own enumerable property values of <code>object</code>.
<br>
<br>
<strong>Note:</strong> Non-object values are coerced to objects.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to query.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the array of property values.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">function</span> <span class="token function">Foo</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>a <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>b <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

Foo<span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>c <span class="token operator">=</span> <span class="token number">3</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">values</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Foo</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2] (iteration order is not guaranteed)</span>

_<span class="token punctuation">.</span><span class="token function">values</span><span class="token punctuation">(</span><span class="token string">'hi'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['h', 'i']</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_valuesinobject-a-_-valuesin-object-"><a id="_valuesinobject"></a><code>_.valuesIn(object)</code></h3>
<p><a href="#_valuesinobject">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10284" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.valuesin" title="See the npm package">Ⓝ</a></p>
<p>Creates an array of the own and inherited enumerable property values
of <code>object</code>.
<br>
<br>
<strong>Note:</strong> Non-object values are coerced to objects.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>object</code> <em>(Object)</em>: The object to query.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the array of property values.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token keyword">function</span> <span class="token function">Foo</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>a <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>b <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

Foo<span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>c <span class="token operator">=</span> <span class="token number">3</span><span class="token punctuation">;</span>

_<span class="token punctuation">.</span><span class="token function">valuesIn</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Foo</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [1, 2, 3] (iteration order is not guaranteed)</span>
</code></pre>
<hr>
</div>
</div>
<div>
<h2 id="-string-methods-"><code>“String” Methods</code></h2>
<div>
<h3 id="-a-id-_camelcasestring-a-_-camelcase-string-"><a id="_camelcasestring"></a><code>_.camelCase([string=''])</code></h3>
<p><a href="#_camelcasestring">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10415" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.camelcase" title="See the npm package">Ⓝ</a></p>
<p>Converts <code>string</code> to <a href="https://en.wikipedia.org/wiki/CamelCase">camel case</a>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to convert.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the camel cased string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">camelCase</span><span class="token punctuation">(</span><span class="token string">'Foo Bar'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'fooBar'</span>

_<span class="token punctuation">.</span><span class="token function">camelCase</span><span class="token punctuation">(</span><span class="token string">'--foo-bar'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'fooBar'</span>

_<span class="token punctuation">.</span><span class="token function">camelCase</span><span class="token punctuation">(</span><span class="token string">'__foo_bar__'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'fooBar'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_capitalizestring-a-_-capitalize-string-"><a id="_capitalizestring"></a><code>_.capitalize([string=''])</code></h3>
<p><a href="#_capitalizestring">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10433" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.capitalize" title="See the npm package">Ⓝ</a></p>
<p>Capitalizes the first character of <code>string</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to capitalize.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the capitalized string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">capitalize</span><span class="token punctuation">(</span><span class="token string">'fred'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'Fred'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_deburrstring-a-_-deburr-string-"><a id="_deburrstring"></a><code>_.deburr([string=''])</code></h3>
<p><a href="#_deburrstring">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10452" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.deburr" title="See the npm package">Ⓝ</a></p>
<p>Deburrs <code>string</code> by converting <a href="https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block">latin-1 supplementary letters</a>#Character_table)
to basic latin letters and removing <a href="https://en.wikipedia.org/wiki/Combining_Diacritical_Marks">combining diacritical marks</a>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to deburr.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the deburred string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">deburr</span><span class="token punctuation">(</span><span class="token string">'déjà vu'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'deja vu'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_endswithstring-target-positionstringlength-a-_-endswith-string-target-position-string-length-"><a id="_endswithstring-target-positionstringlength"></a><code>_.endsWith([string=''], [target], [position=string.length])</code></h3>
<p><a href="#_endswithstring-target-positionstringlength">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10478" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.endswith" title="See the npm package">Ⓝ</a></p>
<p>Checks if <code>string</code> ends with the given target string.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to search.</li>
<li><code>[target]</code> <em>(string)</em>: The string to search for.</li>
<li><code>[position=string.length]</code> <em>(number)</em>: The position to search from.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(boolean)</em>:  Returns <code>true</code> if <code>string</code> ends with <code>target</code>, else <code>false</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">endsWith</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token string">'c'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>

_<span class="token punctuation">.</span><span class="token function">endsWith</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; false</span>

_<span class="token punctuation">.</span><span class="token function">endsWith</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_escapestring-a-_-escape-string-"><a id="_escapestring"></a><code>_.escape([string=''])</code></h3>
<p><a href="#_escapestring">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10523" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.escape" title="See the npm package">Ⓝ</a></p>
<p>Converts the characters "&amp;", "&lt;", "&gt;", '"', "'", and "`", in <code>string</code> to
their corresponding HTML entities.
<br>
<br>
<strong>Note:</strong> No other characters are escaped. To escape additional characters
use a third-party library like <a href="https://mths.be/he"><em>he</em></a>.
<br>
<br>
Though the "&gt;" character is escaped for symmetry, characters like
"&gt;" and "/" don't need escaping in HTML and have no special meaning
unless they're part of a tag or unquoted attribute value.
See <a href="https://mathiasbynens.be/notes/ambiguous-ampersands">Mathias Bynens's article</a>
(under "semi-related fun fact") for more details.
<br>
<br>
Backticks are escaped because in Internet Explorer &lt; 9, they can break out
of attribute values or HTML comments. See <a href="https://html5sec.org/#59">#59</a>,
<a href="https://html5sec.org/#102">#102</a>, <a href="https://html5sec.org/#108">#108</a>, and
<a href="https://html5sec.org/#133">#133</a> of the <a href="https://html5sec.org/">HTML5 Security Cheatsheet</a>
for more details.
<br>
<br>
When working with HTML you should always <a href="http://wonko.com/post/html-escaping">quote attribute values</a>
to reduce XSS vectors.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to escape.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the escaped string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">escape</span><span class="token punctuation">(</span><span class="token string">'fred, barney, &amp; pebbles'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'fred, barney, &amp;amp; pebbles'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_escaperegexpstring-a-_-escaperegexp-string-"><a id="_escaperegexpstring"></a><code>_.escapeRegExp([string=''])</code></h3>
<p><a href="#_escaperegexpstring">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10545" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.escaperegexp" title="See the npm package">Ⓝ</a></p>
<p>Escapes the <code>RegExp</code> special characters "\", "/", "^", "$", ".", "|", "?",
"*", "+", "(", ")", "[", "]", "{" and "}" in <code>string</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to escape.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the escaped string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">escapeRegExp</span><span class="token punctuation">(</span><span class="token string">'[lodash](https://lodash.com/)'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; '\[lodash\]\(https:\/\/lodash\.com\/\)'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_kebabcasestring-a-_-kebabcase-string-"><a id="_kebabcasestring"></a><code>_.kebabCase([string=''])</code></h3>
<p><a href="#_kebabcasestring">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10571" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.kebabcase" title="See the npm package">Ⓝ</a></p>
<p>Converts <code>string</code> to <a href="https://en.wikipedia.org/wiki/Letter_case#Special_case_styles">kebab case</a>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to convert.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the kebab cased string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">kebabCase</span><span class="token punctuation">(</span><span class="token string">'Foo Bar'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'foo-bar'</span>

_<span class="token punctuation">.</span><span class="token function">kebabCase</span><span class="token punctuation">(</span><span class="token string">'fooBar'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'foo-bar'</span>

_<span class="token punctuation">.</span><span class="token function">kebabCase</span><span class="token punctuation">(</span><span class="token string">'__foo_bar__'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'foo-bar'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_padstring-length0-chars-a-_-pad-string-length-0-chars-"><a id="_padstring-length0-chars"></a><code>_.pad([string=''], [length=0], [chars=' '])</code></h3>
<p><a href="#_padstring-length0-chars">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10597" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.pad" title="See the npm package">Ⓝ</a></p>
<p>Pads <code>string</code> on the left and right sides if it's shorter than <code>length</code>.
Padding characters are truncated if they can't be evenly divided by <code>length</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to pad.</li>
<li><code>[length=0]</code> <em>(number)</em>: The padding length.</li>
<li><code>[chars=' ']</code> <em>(string)</em>: The string used as padding.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the padded string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">pad</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token number">8</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; '  abc   '</span>

_<span class="token punctuation">.</span><span class="token function">pad</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token number">8</span><span class="token punctuation">,</span> <span class="token string">'_-'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; '_-abc_-_'</span>

_<span class="token punctuation">.</span><span class="token function">pad</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'abc'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_padleftstring-length0-chars-a-_-padleft-string-length-0-chars-"><a id="_padleftstring-length0-chars"></a><code>_.padLeft([string=''], [length=0], [chars=' '])</code></h3>
<p><a href="#_padleftstring-length0-chars">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10635" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.padleft" title="See the npm package">Ⓝ</a></p>
<p>Pads <code>string</code> on the left side if it's shorter than <code>length</code>. Padding
characters are truncated if they exceed <code>length</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to pad.</li>
<li><code>[length=0]</code> <em>(number)</em>: The padding length.</li>
<li><code>[chars=' ']</code> <em>(string)</em>: The string used as padding.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the padded string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">padLeft</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; '   abc'</span>

_<span class="token punctuation">.</span><span class="token function">padLeft</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">,</span> <span class="token string">'_-'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; '_-_abc'</span>

_<span class="token punctuation">.</span><span class="token function">padLeft</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'abc'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_padrightstring-length0-chars-a-_-padright-string-length-0-chars-"><a id="_padrightstring-length0-chars"></a><code>_.padRight([string=''], [length=0], [chars=' '])</code></h3>
<p><a href="#_padrightstring-length0-chars">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10659" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.padright" title="See the npm package">Ⓝ</a></p>
<p>Pads <code>string</code> on the right side if it's shorter than <code>length</code>. Padding
characters are truncated if they exceed <code>length</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to pad.</li>
<li><code>[length=0]</code> <em>(number)</em>: The padding length.</li>
<li><code>[chars=' ']</code> <em>(string)</em>: The string used as padding.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the padded string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">padRight</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'abc   '</span>

_<span class="token punctuation">.</span><span class="token function">padRight</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">,</span> <span class="token string">'_-'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'abc_-_'</span>

_<span class="token punctuation">.</span><span class="token function">padRight</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'abc'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_parseintstring-radix-a-_-parseint-string-radix-"><a id="_parseintstring-radix"></a><code>_.parseInt(string, [radix])</code></h3>
<p><a href="#_parseintstring-radix">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10684" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.parseint" title="See the npm package">Ⓝ</a></p>
<p>Converts <code>string</code> to an integer of the specified radix. If <code>radix</code> is
<code>undefined</code> or <code>0</code>, a <code>radix</code> of <code>10</code> is used unless <code>value</code> is a hexadecimal,
in which case a <code>radix</code> of <code>16</code> is used.
<br>
<br>
<strong>Note:</strong> This method aligns with the <a href="https://es5.github.io/#E">ES5 implementation</a>
of <code>parseInt</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>string</code> <em>(string)</em>: The string to convert.</li>
<li><code>[radix]</code> <em>(number)</em>: The radix to interpret <code>value</code> by.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(number)</em>:  Returns the converted integer.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">parseInt</span><span class="token punctuation">(</span><span class="token string">'08'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 8</span>

_<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">'6'</span><span class="token punctuation">,</span> <span class="token string">'08'</span><span class="token punctuation">,</span> <span class="token string">'10'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> _<span class="token punctuation">.</span>parseInt<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; [6, 8, 10]</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_repeatstring-n0-a-_-repeat-string-n-0-"><a id="_repeatstring-n0"></a><code>_.repeat([string=''], [n=0])</code></h3>
<p><a href="#_repeatstring-n0">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10717" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.repeat" title="See the npm package">Ⓝ</a></p>
<p>Repeats the given string <code>n</code> times.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to repeat.</li>
<li><code>[n=0]</code> <em>(number)</em>: The number of times to repeat the string.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the repeated string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span><span class="token string">'*'</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; '***'</span>

_<span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'abcabc'</span>

_<span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ''</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_snakecasestring-a-_-snakecase-string-"><a id="_snakecasestring"></a><code>_.snakeCase([string=''])</code></h3>
<p><a href="#_snakecasestring">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10756" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.snakecase" title="See the npm package">Ⓝ</a></p>
<p>Converts <code>string</code> to <a href="https://en.wikipedia.org/wiki/Snake_case">snake case</a>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to convert.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the snake cased string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">snakeCase</span><span class="token punctuation">(</span><span class="token string">'Foo Bar'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'foo_bar'</span>

_<span class="token punctuation">.</span><span class="token function">snakeCase</span><span class="token punctuation">(</span><span class="token string">'fooBar'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'foo_bar'</span>

_<span class="token punctuation">.</span><span class="token function">snakeCase</span><span class="token punctuation">(</span><span class="token string">'--foo-bar'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'foo_bar'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_startcasestring-a-_-startcase-string-"><a id="_startcasestring"></a><code>_.startCase([string=''])</code></h3>
<p><a href="#_startcasestring">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10779" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.startcase" title="See the npm package">Ⓝ</a></p>
<p>Converts <code>string</code> to <a href="https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage">start case</a>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to convert.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the start cased string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">startCase</span><span class="token punctuation">(</span><span class="token string">'--foo-bar'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'Foo Bar'</span>

_<span class="token punctuation">.</span><span class="token function">startCase</span><span class="token punctuation">(</span><span class="token string">'fooBar'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'Foo Bar'</span>

_<span class="token punctuation">.</span><span class="token function">startCase</span><span class="token punctuation">(</span><span class="token string">'__foo_bar__'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'Foo Bar'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_startswithstring-target-position0-a-_-startswith-string-target-position-0-"><a id="_startswithstring-target-position0"></a><code>_.startsWith([string=''], [target], [position=0])</code></h3>
<p><a href="#_startswithstring-target-position0">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10804" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.startswith" title="See the npm package">Ⓝ</a></p>
<p>Checks if <code>string</code> starts with the given target string.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to search.</li>
<li><code>[target]</code> <em>(string)</em>: The string to search for.</li>
<li><code>[position=0]</code> <em>(number)</em>: The position to search from.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(boolean)</em>:  Returns <code>true</code> if <code>string</code> starts with <code>target</code>, else <code>false</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">startsWith</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token string">'a'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>

_<span class="token punctuation">.</span><span class="token function">startsWith</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; false</span>

_<span class="token punctuation">.</span><span class="token function">startsWith</span><span class="token punctuation">(</span><span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; true</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_templatestring-options-a-_-template-string-options-"><a id="_templatestring-options"></a><code>_.template([string=''], [options])</code></h3>
<p><a href="#_templatestring-options">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10909" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.template" title="See the npm package">Ⓝ</a></p>
<p>Creates a compiled template function that can interpolate data properties
in "interpolate" delimiters, HTML-escape interpolated data properties in
"escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
properties may be accessed as free variables in the template. If a setting
object is provided it takes precedence over <code>_.templateSettings</code> values.
<br>
<br>
<strong>Note:</strong> In the development build <code>_.template</code> utilizes
<a href="http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl">sourceURLs</a>
for easier debugging.
<br>
<br>
For more information on precompiling templates see
<a href="https://lodash.com/custom-builds">lodash's custom builds documentation</a>.
<br>
<br>
For more information on Chrome extension sandboxes see
<a href="https://developer.chrome.com/extensions/sandboxingEval">Chrome's extensions documentation</a>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The template string.</li>
<li><code>[options]</code> <em>(Object)</em>: The options object.</li>
<li><code>[options.escape]</code> <em>(RegExp)</em>: The HTML "escape" delimiter.</li>
<li><code>[options.evaluate]</code> <em>(RegExp)</em>: The "evaluate" delimiter.</li>
<li><code>[options.imports]</code> <em>(Object)</em>: An object to import into the template as free variables.</li>
<li><code>[options.interpolate]</code> <em>(RegExp)</em>: The "interpolate" delimiter.</li>
<li><code>[options.sourceURL]</code> <em>(string)</em>: The sourceURL of the template's compiled source.</li>
<li><code>[options.variable]</code> <em>(string)</em>: The data object variable name.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Function)</em>:  Returns the compiled template function.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js"><span class="token comment" spellcheck="true">// using the "interpolate" delimiter to create a compiled template</span>
<span class="token keyword">var</span> compiled <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">template</span><span class="token punctuation">(</span><span class="token string">'hello &lt;%= user %&gt;!'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">compiled</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'fred'</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'hello fred!'</span>

<span class="token comment" spellcheck="true">// using the HTML "escape" delimiter to escape data property values</span>
<span class="token keyword">var</span> compiled <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">template</span><span class="token punctuation">(</span><span class="token string">'&lt;b&gt;&lt;%- value %&gt;&lt;/b&gt;'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">compiled</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'value'</span><span class="token punctuation">:</span> <span class="token string">'&lt;script&gt;'</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; '&lt;b&gt;&amp;lt;script&amp;gt;&lt;/b&gt;'</span>

<span class="token comment" spellcheck="true">// using the "evaluate" delimiter to execute JavaScript and generate HTML</span>
<span class="token keyword">var</span> compiled <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">template</span><span class="token punctuation">(</span><span class="token string">'&lt;% _.forEach(users, function(user) { %&gt;&lt;li&gt;&lt;%- user %&gt;&lt;/li&gt;&lt;% }); %&gt;'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">compiled</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'users'</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'fred'</span><span class="token punctuation">,</span> <span class="token string">'barney'</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; '&lt;li&gt;fred&lt;/li&gt;&lt;li&gt;barney&lt;/li&gt;'</span>

<span class="token comment" spellcheck="true">// using the internal `print` function in "evaluate" delimiters</span>
<span class="token keyword">var</span> compiled <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">template</span><span class="token punctuation">(</span><span class="token string">'&lt;% print("hello " + user); %&gt;!'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">compiled</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'barney'</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'hello barney!'</span>

<span class="token comment" spellcheck="true">// using the ES delimiter as an alternative to the default "interpolate" delimiter</span>
<span class="token keyword">var</span> compiled <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">template</span><span class="token punctuation">(</span><span class="token string">'hello ${ user }!'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">compiled</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'pebbles'</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'hello pebbles!'</span>

<span class="token comment" spellcheck="true">// using custom template delimiters</span>
_<span class="token punctuation">.</span>templateSettings<span class="token punctuation">.</span>interpolate <span class="token operator">=</span> <span class="token regex">/{{([\s\S]+?)}}/g</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> compiled <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">template</span><span class="token punctuation">(</span><span class="token string">'hello {{ user }}!'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">compiled</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'user'</span><span class="token punctuation">:</span> <span class="token string">'mustache'</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'hello mustache!'</span>

<span class="token comment" spellcheck="true">// using backslashes to treat delimiters as plain text</span>
<span class="token keyword">var</span> compiled <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">template</span><span class="token punctuation">(</span><span class="token string">'&lt;%= "\\&lt;%- value %\\&gt;" %&gt;'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">compiled</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'value'</span><span class="token punctuation">:</span> <span class="token string">'ignored'</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; '&lt;%- value %&gt;'</span>

<span class="token comment" spellcheck="true">// using the `imports` option to import `jQuery` as `jq`</span>
<span class="token keyword">var</span> text <span class="token operator">=</span> <span class="token string">'&lt;% jq.each(users, function(user) { %&gt;&lt;li&gt;&lt;%- user %&gt;&lt;/li&gt;&lt;% }); %&gt;'</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> compiled <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">template</span><span class="token punctuation">(</span>text<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'imports'</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token string">'jq'</span><span class="token punctuation">:</span> jQuery <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">compiled</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">'users'</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'fred'</span><span class="token punctuation">,</span> <span class="token string">'barney'</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; '&lt;li&gt;fred&lt;/li&gt;&lt;li&gt;barney&lt;/li&gt;'</span>

<span class="token comment" spellcheck="true">// using the `sourceURL` option to specify a custom sourceURL for the template</span>
<span class="token keyword">var</span> compiled <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">template</span><span class="token punctuation">(</span><span class="token string">'hello &lt;%= user %&gt;!'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'sourceURL'</span><span class="token punctuation">:</span> <span class="token string">'/basic/greeting.jst'</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">compiled</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector</span>

<span class="token comment" spellcheck="true">// using the `variable` option to ensure a with-statement isn't used in the compiled template</span>
<span class="token keyword">var</span> compiled <span class="token operator">=</span> _<span class="token punctuation">.</span><span class="token function">template</span><span class="token punctuation">(</span><span class="token string">'hi &lt;%= data.user %&gt;!'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">'variable'</span><span class="token punctuation">:</span> <span class="token string">'data'</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
compiled<span class="token punctuation">.</span>source<span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; function(data) {</span>
<span class="token comment" spellcheck="true">//   var __t, __p = '';</span>
<span class="token comment" spellcheck="true">//   __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';</span>
<span class="token comment" spellcheck="true">//   return __p;</span>
<span class="token comment" spellcheck="true">// }</span>

<span class="token comment" spellcheck="true">// using the `source` property to inline compiled templates for meaningful</span>
<span class="token comment" spellcheck="true">// line numbers in error messages and a stack trace</span>
fs<span class="token punctuation">.</span><span class="token function">writeFileSync</span><span class="token punctuation">(</span>path<span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span>cwd<span class="token punctuation">,</span> <span class="token string">'jst.js'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">'\
  var JST = {\
    "main": '</span> <span class="token operator">+</span> _<span class="token punctuation">.</span><span class="token function">template</span><span class="token punctuation">(</span>mainText<span class="token punctuation">)</span><span class="token punctuation">.</span>source <span class="token operator">+</span> <span class="token string">'\
  };\
'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_trimstring-charswhitespace-a-_-trim-string-chars-whitespace-"><a id="_trimstring-charswhitespace"></a><code>_.trim([string=''], [chars=whitespace])</code></h3>
<p><a href="#_trimstring-charswhitespace">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11036" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.trim" title="See the npm package">Ⓝ</a></p>
<p>Removes leading and trailing whitespace or specified characters from <code>string</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to trim.</li>
<li><code>[chars=whitespace]</code> <em>(string)</em>: The characters to trim.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the trimmed string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">trim</span><span class="token punctuation">(</span><span class="token string">'  abc  '</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'abc'</span>

_<span class="token punctuation">.</span><span class="token function">trim</span><span class="token punctuation">(</span><span class="token string">'-_-abc-_-'</span><span class="token punctuation">,</span> <span class="token string">'_-'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'abc'</span>

_<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">'  foo  '</span><span class="token punctuation">,</span> <span class="token string">'  bar  '</span><span class="token punctuation">]</span><span class="token punctuation">,</span> _<span class="token punctuation">.</span>trim<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['foo', 'bar']</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_trimleftstring-charswhitespace-a-_-trimleft-string-chars-whitespace-"><a id="_trimleftstring-charswhitespace"></a><code>_.trimLeft([string=''], [chars=whitespace])</code></h3>
<p><a href="#_trimleftstring-charswhitespace">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11067" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.trimleft" title="See the npm package">Ⓝ</a></p>
<p>Removes leading whitespace or specified characters from <code>string</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to trim.</li>
<li><code>[chars=whitespace]</code> <em>(string)</em>: The characters to trim.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the trimmed string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">trimLeft</span><span class="token punctuation">(</span><span class="token string">'  abc  '</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'abc  '</span>

_<span class="token punctuation">.</span><span class="token function">trimLeft</span><span class="token punctuation">(</span><span class="token string">'-_-abc-_-'</span><span class="token punctuation">,</span> <span class="token string">'_-'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'abc-_-'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_trimrightstring-charswhitespace-a-_-trimright-string-chars-whitespace-"><a id="_trimrightstring-charswhitespace"></a><code>_.trimRight([string=''], [chars=whitespace])</code></h3>
<p><a href="#_trimrightstring-charswhitespace">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11097" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.trimright" title="See the npm package">Ⓝ</a></p>
<p>Removes trailing whitespace or specified characters from <code>string</code>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to trim.</li>
<li><code>[chars=whitespace]</code> <em>(string)</em>: The characters to trim.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the trimmed string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">trimRight</span><span class="token punctuation">(</span><span class="token string">'  abc  '</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; '  abc'</span>

_<span class="token punctuation">.</span><span class="token function">trimRight</span><span class="token punctuation">(</span><span class="token string">'-_-abc-_-'</span><span class="token punctuation">,</span> <span class="token string">'_-'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; '-_-abc'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_truncstring-options-optionslength30-optionsomission-optionsseparator-a-_-trunc-string-options-options-length-30-options-omission-options-separator-"><a id="_truncstring-options-optionslength30-optionsomission-optionsseparator"></a><code>_.trunc([string=''], [options], [options.length=30], [options.omission='...'], [options.separator])</code></h3>
<p><a href="#_truncstring-options-optionslength30-optionsomission-optionsseparator">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11149" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.trunc" title="See the npm package">Ⓝ</a></p>
<p>Truncates <code>string</code> if it's longer than the given maximum string length.
The last characters of the truncated string are replaced with the omission
string which defaults to "...".</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to truncate.</li>
<li><code>[options]</code> <em>(Object|number)</em>: The options object or maximum string length.</li>
<li><code>[options.length=30]</code> <em>(number)</em>: The maximum string length.</li>
<li><code>[options.omission='...']</code> <em>(string)</em>: The string to indicate text is omitted.</li>
<li><code>[options.separator]</code> <em>(RegExp|string)</em>: The separator pattern to truncate to.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the truncated string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">trunc</span><span class="token punctuation">(</span><span class="token string">'hi-diddly-ho there, neighborino'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'hi-diddly-ho there, neighbo...'</span>

_<span class="token punctuation">.</span><span class="token function">trunc</span><span class="token punctuation">(</span><span class="token string">'hi-diddly-ho there, neighborino'</span><span class="token punctuation">,</span> <span class="token number">24</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'hi-diddly-ho there, n...'</span>

_<span class="token punctuation">.</span><span class="token function">trunc</span><span class="token punctuation">(</span><span class="token string">'hi-diddly-ho there, neighborino'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
  <span class="token string">'length'</span><span class="token punctuation">:</span> <span class="token number">24</span><span class="token punctuation">,</span>
  <span class="token string">'separator'</span><span class="token punctuation">:</span> <span class="token string">' '</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'hi-diddly-ho there,...'</span>

_<span class="token punctuation">.</span><span class="token function">trunc</span><span class="token punctuation">(</span><span class="token string">'hi-diddly-ho there, neighborino'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
  <span class="token string">'length'</span><span class="token punctuation">:</span> <span class="token number">24</span><span class="token punctuation">,</span>
  <span class="token string">'separator'</span><span class="token punctuation">:</span> <span class="token regex">/,? +/</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'hi-diddly-ho there...'</span>

_<span class="token punctuation">.</span><span class="token function">trunc</span><span class="token punctuation">(</span><span class="token string">'hi-diddly-ho there, neighborino'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
  <span class="token string">'omission'</span><span class="token punctuation">:</span> <span class="token string">' [...]'</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'hi-diddly-ho there, neig [...]'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_unescapestring-a-_-unescape-string-"><a id="_unescapestring"></a><code>_.unescape([string=''])</code></h3>
<p><a href="#_unescapestring">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11219" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.unescape" title="See the npm package">Ⓝ</a></p>
<p>The inverse of <code>_.escape</code>; this method converts the HTML entities
<code>&amp;amp;</code>, <code>&amp;lt;</code>, <code>&amp;gt;</code>, <code>&amp;quot;</code>, <code>&amp;#39;</code>, and <code>&amp;#96;</code> in <code>string</code> to their
corresponding characters.
<br>
<br>
<strong>Note:</strong> No other HTML entities are unescaped. To unescape additional HTML
entities use a third-party library like <a href="https://mths.be/he"><em>he</em></a>.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to unescape.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(string)</em>:  Returns the unescaped string.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">unescape</span><span class="token punctuation">(</span><span class="token string">'fred, barney, &amp;amp; pebbles'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; 'fred, barney, &amp; pebbles'</span>
</code></pre>
<hr>
</div>
<div>
<h3 id="-a-id-_wordsstring-pattern-a-_-words-string-pattern-"><a id="_wordsstring-pattern"></a><code>_.words([string=''], [pattern])</code></h3>
<p><a href="#_wordsstring-pattern">#</a> <a href="https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11244" title="View in source">Ⓢ</a> <a href="#array" title="Jump back to the TOC.">Ⓣ</a> <a href="https://www.npmjs.com/package/lodash.words" title="See the npm package">Ⓝ</a></p>
<p>Splits <code>string</code> into an array of its words.</p>
<h4 id="-">参数</h4>
<ol>
<li><code>[string='']</code> <em>(string)</em>: The string to inspect.</li>
<li><code>[pattern]</code> <em>(RegExp|string)</em>: The pattern to match words.</li>
</ol>
<h4 id="-">返回值</h4>
<p><em>(Array)</em>:  Returns the words of <code>string</code>.</p>
<h4 id="-">例子</h4>
<pre><code class="language-js">_<span class="token punctuation">.</span><span class="token function">words</span><span class="token punctuation">(</span><span class="token string">'fred, barney, &amp; pebbles'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['fred', 'barney', 'pebbles']</span>

_<span class="token punctuation">.</span><span class="token function">words</span><span class="token punctuation">(</span><span class="token string">'fred, barney, &amp; pebbles'</span><span class="token punctuation">,</span> <span class="token regex">/[^, ]+/g</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// =&gt; ['fred', 'barney', '&amp;', 'pebbles']</span>
</code></pre>
<hr>
</div>
</div>
</div>